ソースを参照

Fixes #1846 restoring deleted files

main
Eric Amodio 2年前
コミット
5d2f0a9318
12個のファイルの変更23行の追加31行の削除
  1. +1
    -0
      CHANGELOG.md
  2. +12
    -4
      src/commands/gitCommands.actions.ts
  3. +4
    -8
      src/env/node/git/git.ts
  4. +1
    -1
      src/env/node/git/localGitProvider.ts
  5. +1
    -1
      src/git/gitProvider.ts
  6. +1
    -1
      src/git/gitProviderService.ts
  7. +1
    -1
      src/premium/github/githubGitProvider.ts
  8. +0
    -4
      src/views/nodes/commitFileNode.ts
  9. +0
    -4
      src/views/nodes/fileRevisionAsCommitNode.ts
  10. +0
    -4
      src/views/nodes/resultsFileNode.ts
  11. +1
    -2
      src/views/nodes/viewNode.ts
  12. +1
    -1
      src/views/viewCommands.ts

+ 1
- 0
CHANGELOG.md ファイルの表示

@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#1846](https://github.com/gitkraken/vscode-gitlens/issues/1846) - Restoring (checkout) a deleted file from a commit doesn't work
- Fixes [#1844](https://github.com/gitkraken/vscode-gitlens/issues/1844) - Autolinked issues aren't properly paged when there are too many commits
- Fixes [#1843](https://github.com/gitkraken/vscode-gitlens/issues/1843) - Compare references doesn't work if you have multiple repos open

+ 12
- 4
src/commands/gitCommands.actions.ts ファイルの表示

@ -655,10 +655,18 @@ export namespace GitActions {
);
}
export async function restoreFile(file: string | GitFile, ref: GitRevisionReference) {
void (await Container.instance.git.checkout(ref.repoPath, ref.ref, {
fileName: typeof file === 'string' ? file : file.path,
}));
export async function restoreFile(file: string | GitFile, revision: GitRevisionReference) {
let path;
let ref;
if (typeof file === 'string') {
path = file;
ref = revision.ref;
} else {
path = file.path;
ref = file.status === 'D' ? `${revision.ref}^` : revision.ref;
}
void (await Container.instance.git.checkout(revision.repoPath, ref, { path: path }));
}
export async function reveal(

+ 4
- 8
src/env/node/git/git.ts ファイルの表示

@ -384,21 +384,17 @@ export class Git {
}
}
checkout(
repoPath: string,
ref: string,
{ createBranch, fileName }: { createBranch?: string; fileName?: string } = {},
) {
checkout(repoPath: string, ref: string, { createBranch, path }: { createBranch?: string; path?: string } = {}) {
const params = ['checkout'];
if (createBranch) {
params.push('-b', createBranch, ref, '--');
} else {
params.push(ref, '--');
if (fileName) {
[fileName, repoPath] = splitPath(fileName, repoPath, true);
if (path) {
[path, repoPath] = splitPath(path, repoPath, true);
params.push(fileName);
params.push(path);
}
}

+ 1
- 1
src/env/node/git/localGitProvider.ts ファイルの表示

@ -835,7 +835,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
async checkout(
repoPath: string,
ref: string,
options?: { createBranch?: string } | { fileName?: string },
options?: { createBranch?: string } | { path?: string },
): Promise<void> {
const cc = Logger.getCorrelationContext();

+ 1
- 1
src/git/gitProvider.ts ファイルの表示

@ -136,7 +136,7 @@ export interface GitProvider extends Disposable {
checkout(
repoPath: string,
ref: string,
options?: { createBranch?: string | undefined } | { fileName?: string | undefined },
options?: { createBranch?: string | undefined } | { path?: string | undefined },
): Promise<void>;
resetCaches(
...affects: ('branches' | 'contributors' | 'providers' | 'remotes' | 'stashes' | 'status' | 'tags')[]

+ 1
- 1
src/git/gitProviderService.ts ファイルの表示

@ -947,7 +947,7 @@ export class GitProviderService implements Disposable {
async checkout(
repoPath: string,
ref: string,
options?: { createBranch?: string } | { fileName?: string },
options?: { createBranch?: string } | { path?: string },
): Promise<void> {
const { provider, path } = this.getProvider(repoPath);
return provider.checkout(path, ref, options);

+ 1
- 1
src/premium/github/githubGitProvider.ts ファイルの表示

@ -370,7 +370,7 @@ export class GitHubGitProvider implements GitProvider, Disposable {
async checkout(
_repoPath: string,
_ref: string,
_options?: { createBranch?: string } | { fileName?: string },
_options?: { createBranch?: string } | { path?: string },
): Promise<void> {}
@log()

+ 0
- 4
src/views/nodes/commitFileNode.ts ファイルの表示

@ -25,10 +25,6 @@ export class CommitFileNode
}
override toClipboard(): string {
return this.fileName;
}
get fileName(): string {
return this.file.path;
}

+ 0
- 4
src/views/nodes/fileRevisionAsCommitNode.ts ファイルの表示

@ -41,10 +41,6 @@ export class FileRevisionAsCommitNode extends ViewRefFileNode
return `${this.commit.shortSha}: ${this.commit.summary}`;
}
get fileName(): string {
return this.file.path;
}
get isTip(): boolean {
return (this._options.branch?.current && this._options.branch.sha === this.commit.ref) ?? false;
}

+ 0
- 4
src/views/nodes/resultsFileNode.ts ファイルの表示

@ -23,10 +23,6 @@ export class ResultsFileNode extends ViewRefFileNode implements FileNode {
}
override toClipboard(): string {
return this.fileName;
}
get fileName(): string {
return this.file.path;
}

+ 1
- 2
src/views/nodes/viewNode.ts ファイルの表示

@ -166,10 +166,9 @@ export abstract class ViewRefNode<
export abstract class ViewRefFileNode<TView extends View = View> extends ViewRefNode<TView, GitRevisionReference> {
abstract get file(): GitFile;
abstract get fileName(): string;
override toString(): string {
return `${super.toString()}:${this.fileName}`;
return `${super.toString()}:${this.file.path}`;
}
}

+ 1
- 1
src/views/viewCommands.ts ファイルの表示

@ -636,7 +636,7 @@ export class ViewCommands {
private restore(node: ViewRefFileNode) {
if (!(node instanceof ViewRefFileNode)) return Promise.resolve();
return GitActions.Commit.restoreFile(node.fileName, node.ref);
return GitActions.Commit.restoreFile(node.file, node.ref);
}
@debug()

読み込み中…
キャンセル
保存