Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions extensions/git/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down
6 changes: 4 additions & 2 deletions extensions/git/src/historyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
5 changes: 4 additions & 1 deletion extensions/git/src/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const enum OperationKind {
RevertFiles = 'RevertFiles',
RevertFilesNoProgress = 'RevertFilesNoProgress',
RevList = 'RevList',
RevParse = 'RevParse',
SetBranchUpstream = 'SetBranchUpstream',
Show = 'Show',
Stage = 'Stage',
Expand All @@ -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;

Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down