Bladeren bron

Fixes #2928 create new file on apply

main
Eric Amodio 1 jaar geleden
bovenliggende
commit
8465f708ff
2 gewijzigde bestanden met toevoegingen van 23 en 7 verwijderingen
  1. +1
    -0
      CHANGELOG.md
  2. +22
    -7
      src/git/actions/commit.ts

+ 1
- 0
CHANGELOG.md Bestand weergeven

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#2928](https://github.com/gitkraken/vscode-gitlens/issues/2928) - Apply Changes should create new files when needed
- Fixes [#2896](https://github.com/gitkraken/vscode-gitlens/issues/2896) - Repositories view stuck in loading state
- Fixes issue with "View as [List|Tree]" toggle not working in the _Commit Details_ view

+ 22
- 7
src/git/actions/commit.ts Bestand weergeven

@ -25,16 +25,31 @@ import type { GitRevisionReference } from '../models/reference';
import { getReferenceFromRevision, isUncommitted, isUncommittedStaged } from '../models/reference';
export async function applyChanges(file: string | GitFile, ref1: GitRevisionReference, ref2?: GitRevisionReference) {
// Open the working file to ensure undo will work
await openFile(file, ref1, { preserveFocus: true, preview: false });
let create = 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`;
if (typeof file !== 'string') {
// If the file is `?` (untracked), then this must be a stash, so get the ^3 commit to access the untracked file
if (file.status === '?') {
ref = `${ref}^3`;
create = true;
} else if (file.status === 'A') {
create = true;
}
}
await Container.instance.git.applyChangesToWorkingFile(GitUri.fromFile(file, ref1.repoPath, ref), ref, ref2?.ref);
if (create) {
const uri = GitUri.fromFile(file, ref1.repoPath);
await Container.instance.git.applyChangesToWorkingFile(uri, ref, ref2?.ref);
await openFile(uri, { preserveFocus: true, preview: false });
} else {
// Open the working file to ensure undo will work
await openFile(file, ref1, { preserveFocus: true, preview: false });
await Container.instance.git.applyChangesToWorkingFile(
GitUri.fromFile(file, ref1.repoPath, ref),
ref,
ref2?.ref,
);
}
}
export async function copyIdToClipboard(ref: { repoPath: string; ref: string } | GitCommit) {

Laden…
Annuleren
Opslaan