Bladeren bron

Fixes #2033 untracked files in stashes

main
Eric Amodio 2 jaren geleden
bovenliggende
commit
14d05f567b
4 gewijzigde bestanden met toevoegingen van 26 en 6 verwijderingen
  1. +2
    -1
      CHANGELOG.md
  2. +2
    -1
      src/commands/diffWithPrevious.ts
  3. +14
    -3
      src/commands/gitCommands.actions.ts
  4. +8
    -1
      src/git/gitUri.ts

+ 2
- 1
CHANGELOG.md Bestand weergeven

@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## Fixed
- Fixes [#2033](https://github.com/gitkraken/vscode-gitlens/issues/2033) - Diffing, applying, and restoring untracked files in a stash doesn't work
- Fixes [#2028](https://github.com/gitkraken/vscode-gitlens/issues/2028) - Branch names with special characters '<' also causes errors on the command line &mdash; thanks to [PR #2030](https://github.com/gitkraken/vscode-gitlens/pull/2030) by mcy-kylin ([@mcy-kylin](https://github.com/mcy-kylin))
- Fixes [#2028](https://github.com/gitkraken/vscode-gitlens/issues/2028) - Branch names with special characters like ';$|>' causes errors on the command line (terminal executed git commands)
- Fixes [#2021](https://github.com/gitkraken/vscode-gitlens/issues/2021) - GitLab remote provider uses legacy routes &mdash; thanks to [PR #2022](https://github.com/gitkraken/vscode-gitlens/pull/2022) by Brian Williams ([@Brcrwilliams](https://github.com/Brcrwilliams))
@ -4211,7 +4212,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Initial release but still heavily a work in progress.
[Unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/v12.0.7...HEAD
[unreleased]: https://github.com/gitkraken/vscode-gitlens/compare/v12.0.7...HEAD
[12.0.6]: https://github.com/gitkraken/vscode-gitlens/compare/v12.0.6...gitkraken:v12.0.7
[12.0.6]: https://github.com/gitkraken/vscode-gitlens/compare/v12.0.5...gitkraken:v12.0.6
[12.0.5]: https://github.com/gitkraken/vscode-gitlens/compare/v12.0.4...gitkraken:v12.0.5

+ 2
- 1
src/commands/diffWithPrevious.ts Bestand weergeven

@ -56,7 +56,8 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
uri: args.commit.file.originalUri ?? args.commit.file.uri,
},
rhs: {
sha: args.commit.sha || '',
// If the file is `?` (untracked), then this must be a stash, so get the ^3 commit to access the untracked file
sha: args.commit.file.status === '?' ? `${args.commit.sha}^3` : args.commit.sha || '',
uri: args.commit.file.uri,
},
line: args.line,

+ 14
- 3
src/commands/gitCommands.actions.ts Bestand weergeven

@ -169,9 +169,16 @@ export namespace GitActions {
) {
// Open the working file to ensure undo will work
void (await GitActions.Commit.openFile(file, ref1, { preserveFocus: true, preview: false }));
let ref = ref1.ref;
// If the file is `?` (untracked), then this must be a stash, so get the ^3 commit to access the untracked file
if (typeof file !== 'string' && file.status === '?') {
ref = `${ref}^3`;
}
void (await Container.instance.git.applyChangesToWorkingFile(
GitUri.fromFile(file, ref1.repoPath, ref1.ref),
ref1.ref,
GitUri.fromFile(file, ref1.repoPath, ref),
ref,
ref2?.ref,
));
}
@ -502,7 +509,10 @@ export namespace GitActions {
options = refOrOptions as TextDocumentShowOptions;
} else {
const ref = refOrOptions as GitRevisionReference;
uri = GitUri.fromFile(fileOrUri, ref.repoPath, ref.ref);
// If the file is `?` (untracked), then this must be an untracked file in a stash, so just return
if (typeof fileOrUri !== 'string' && fileOrUri.status === '?') return;
}
options = { preserveFocus: true, preview: false, ...options };
@ -663,7 +673,8 @@ export namespace GitActions {
ref = revision.ref;
} else {
path = file.path;
ref = file.status === 'D' ? `${revision.ref}^` : revision.ref;
ref =
file.status === `?` ? `${revision.ref}^3` : file.status === 'D' ? `${revision.ref}^` : revision.ref;
}
void (await Container.instance.git.checkout(revision.repoPath, ref, { path: path }));

+ 8
- 1
src/git/gitUri.ts Bestand weergeven

@ -230,7 +230,14 @@ export class GitUri extends (Uri as any as UriEx) {
typeof file === 'string' ? file : (original && file.originalPath) || file.path,
repoPath,
);
return !ref ? new GitUri(uri, repoPath) : new GitUri(uri, { repoPath: repoPath, sha: ref });
return !ref
? new GitUri(uri, repoPath)
: new GitUri(uri, {
repoPath: repoPath,
// If the file is `?` (untracked), then this must be a stash, so get the ^3 commit to access the untracked file
sha: typeof file !== 'string' && file.status === '?' ? `${ref}^3` : ref,
});
}
static fromRepoPath(repoPath: string, ref?: string) {

Laden…
Annuleren
Opslaan