瀏覽代碼

Fixes #2928 create new file on apply

main
Eric Amodio 1 年之前
父節點
當前提交
8465f708ff
共有 2 個文件被更改,包括 23 次插入7 次删除
  1. +1
    -0
      CHANGELOG.md
  2. +22
    -7
      src/git/actions/commit.ts

+ 1
- 0
CHANGELOG.md 查看文件

@ -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 查看文件

@ -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) {

Loading…
取消
儲存