瀏覽代碼

Fixes #2394 ensures uncommitted parent is HEAD

main
Eric Amodio 1 年之前
父節點
當前提交
66d3c411b1
共有 4 個檔案被更改,包括 14 行新增3 行删除
  1. +1
    -0
      CHANGELOG.md
  2. +4
    -0
      src/git/gitProviderService.ts
  3. +5
    -3
      src/git/models/commit.ts
  4. +4
    -0
      src/git/models/reference.ts

+ 1
- 0
CHANGELOG.md 查看文件

@ -39,6 +39,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#2394](https://github.com/gitkraken/vscode-gitlens/issues/2394) - Work in progress file diff compares working tree with working tree, instead of working tree with head
- Fixes [#2207](https://github.com/gitkraken/vscode-gitlens/issues/2207) - Error when trying to push individual commit
- Fixes [#2301](https://github.com/gitkraken/vscode-gitlens/issues/2301) - Create Worktree button doesn't work in certain cases
- Fixes [#2382](https://github.com/gitkraken/vscode-gitlens/issues/2382) - commits disappearing from commit details view when they shouldn't

+ 4
- 0
src/git/gitProviderService.ts 查看文件

@ -2303,6 +2303,10 @@ export class GitProviderService implements Disposable {
pathOrUri?: string | Uri,
options?: { timeout?: number },
) {
if (pathOrUri != null && GitRevision.isUncommittedParent(ref)) {
ref = 'HEAD';
}
if (
!ref ||
ref === GitRevision.deletedOrMissing ||

+ 5
- 3
src/git/models/commit.ts 查看文件

@ -173,9 +173,11 @@ export class GitCommit implements GitRevisionReference {
private _resolvedPreviousSha: string | undefined;
get unresolvedPreviousSha(): string {
return (
this._resolvedPreviousSha ?? (this.file != null ? this.file.previousSha : this.parents[0]) ?? `${this.sha}^`
);
const previousSha =
this._resolvedPreviousSha ??
(this.file != null ? this.file.previousSha : this.parents[0]) ??
`${this.sha}^`;
return GitRevision.isUncommittedParent(previousSha) ? 'HEAD' : previousSha;
}
private _etagFileSystem: number | undefined;

+ 4
- 0
src/git/models/reference.ts 查看文件

@ -47,6 +47,10 @@ export namespace GitRevision {
return ref === uncommitted || ref === uncommittedStaged || (!exact && isMatch(uncommittedRegex, ref));
}
export function isUncommittedParent(ref: string | undefined) {
return ref === `${uncommitted}^` || ref === `${uncommittedStaged}^`;
}
export function isUncommittedStaged(ref: string | undefined, exact: boolean = false): boolean {
return ref === uncommittedStaged || (!exact && isMatch(uncommittedStagedRegex, ref));
}

Loading…
取消
儲存