Git - provide correct editor title for resources under the "All Changes" node (#194273)

This commit is contained in:
Ladislau Szomoru 2023-09-27 12:05:58 +02:00 committed by GitHub
parent 8ef15195d4
commit 3a0b6baa61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 3 deletions

View file

@ -2555,6 +2555,18 @@ export class Repository {
return { ahead: Number(ahead) || 0, behind: Number(behind) || 0 };
}
async revParse(ref: string): Promise<string | undefined> {
try {
const result = await this.exec(['rev-parse', ref]);
if (result.stderr) {
return undefined;
}
return result.stdout.trim();
} catch (err) {
return undefined;
}
}
async updateSubmodules(paths: string[]): Promise<void> {
const args = ['submodule', 'update'];

View file

@ -76,9 +76,11 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
}
const optionsRef = options.limit.id;
const historyItemGroupIdRef = await this.repository.revParse(historyItemGroupId) ?? '';
const [commits, summary] = await Promise.all([
this.repository.log({ range: `${optionsRef}..${historyItemGroupId}`, sortByAuthorDate: true }),
this.getSummaryHistoryItem(optionsRef, historyItemGroupId)
this.repository.log({ range: `${optionsRef}..${historyItemGroupIdRef}`, sortByAuthorDate: true }),
this.getSummaryHistoryItem(optionsRef, historyItemGroupIdRef)
]);
const historyItems = commits.length === 0 ? [] : [summary];

View file

@ -54,6 +54,7 @@ export const enum OperationKind {
RevertFiles = 'RevertFiles',
RevertFilesNoProgress = 'RevertFilesNoProgress',
RevList = 'RevList',
RevParse = 'RevParse',
SetBranchUpstream = 'SetBranchUpstream',
Show = 'Show',
Stage = 'Stage',
@ -70,7 +71,7 @@ export type Operation = AddOperation | ApplyOperation | BlameOperation | BranchO
GetBranchOperation | GetBranchesOperation | GetCommitTemplateOperation | GetObjectDetailsOperation | GetRefsOperation | GetRemoteRefsOperation |
HashObjectOperation | IgnoreOperation | LogOperation | LogFileOperation | MergeOperation | MergeAbortOperation | MergeBaseOperation |
MoveOperation | PostCommitCommandOperation | PullOperation | PushOperation | RemoteOperation | RenameBranchOperation | RemoveOperation |
ResetOperation | RebaseOperation | RebaseAbortOperation | RebaseContinueOperation | RevertFilesOperation | RevListOperation |
ResetOperation | RebaseOperation | RebaseAbortOperation | RebaseContinueOperation | RevertFilesOperation | RevListOperation | RevParseOperation |
SetBranchUpstreamOperation | ShowOperation | StageOperation | StatusOperation | StashOperation | SubmoduleUpdateOperation | SyncOperation |
TagOperation;
@ -119,6 +120,7 @@ export type RebaseAbortOperation = BaseOperation & { kind: OperationKind.RebaseA
export type RebaseContinueOperation = BaseOperation & { kind: OperationKind.RebaseContinue };
export type RevertFilesOperation = BaseOperation & { kind: OperationKind.RevertFiles };
export type RevListOperation = BaseOperation & { kind: OperationKind.RevList };
export type RevParseOperation = BaseOperation & { kind: OperationKind.RevParse };
export type SetBranchUpstreamOperation = BaseOperation & { kind: OperationKind.SetBranchUpstream };
export type ShowOperation = BaseOperation & { kind: OperationKind.Show };
export type StageOperation = BaseOperation & { kind: OperationKind.Stage };
@ -173,6 +175,7 @@ export const Operation = {
RebaseContinue: { kind: OperationKind.RebaseContinue, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as RebaseContinueOperation,
RevertFiles: (showProgress: boolean) => ({ kind: OperationKind.RevertFiles, blocking: false, readOnly: false, remote: false, retry: false, showProgress } as RevertFilesOperation),
RevList: { kind: OperationKind.RevList, blocking: false, readOnly: true, remote: false, retry: false, showProgress: false } as RevListOperation,
RevParse: { kind: OperationKind.RevParse, blocking: false, readOnly: true, remote: false, retry: false, showProgress: false } as RevParseOperation,
SetBranchUpstream: { kind: OperationKind.SetBranchUpstream, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as SetBranchUpstreamOperation,
Show: { kind: OperationKind.Show, blocking: false, readOnly: true, remote: false, retry: false, showProgress: false } as ShowOperation,
Stage: { kind: OperationKind.Stage, blocking: false, readOnly: false, remote: false, retry: false, showProgress: true } as StageOperation,

View file

@ -1606,6 +1606,10 @@ export class Repository implements Disposable {
return await this.run(Operation.RevList, () => this.repository.getCommitCount(range));
}
async revParse(ref: string): Promise<string | undefined> {
return await this.run(Operation.RevParse, () => this.repository.revParse(ref));
}
async reset(treeish: string, hard?: boolean): Promise<void> {
await this.run(Operation.Reset, () => this.repository.reset(treeish, hard));
}