Skip to content

Commit 281249c

Browse files
committed
Adds ref range input into history/log git command
1 parent 297d165 commit 281249c

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Adds ability to enter reference ranges (e.g. `main...release/1.0`) to the _Git Command Palette_'s _history_ command
12+
913
### Fixed
1014

1115
- Fixes [#1148](https://github.com/eamodio/vscode-gitlens/issues/1148) - Follow renames on File History cannot load more history

src/commands/git/log.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export class LogGitCommand extends QuickCommand<State> {
115115
placeholder: 'Choose a branch or tag to show its commit history',
116116
picked: context.selectedBranchOrTag?.ref,
117117
value: context.selectedBranchOrTag == null ? state.reference?.ref : undefined,
118+
ranges: true,
118119
});
119120
if (result === StepResult.Break) {
120121
// If we skipped the previous step, make sure we back up past it

src/commands/quickCommand.steps.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import {
6868
OpenChangedFilesCommandQuickPickItem,
6969
OpenRemoteResourceCommandQuickPickItem,
7070
ReferencesQuickPickItem,
71+
RefQuickPickItem,
7172
RepositoryQuickPickItem,
7273
RevealInSideBarQuickPickItem,
7374
SearchForCommitQuickPickItem,
@@ -255,7 +256,7 @@ export async function getBranchesAndOrTags(
255256
]);
256257
}
257258

258-
export function getValidateGitReferenceFn(repos: Repository | Repository[]) {
259+
export function getValidateGitReferenceFn(repos: Repository | Repository[], options?: { ranges?: boolean }) {
259260
return async (quickpick: QuickPick<any>, value: string) => {
260261
let inRefMode = false;
261262
if (value.startsWith('#')) {
@@ -269,6 +270,13 @@ export function getValidateGitReferenceFn(repos: Repository | Repository[]) {
269270
repos = repos[0];
270271
}
271272

273+
if (inRefMode && options?.ranges && GitRevision.isRange(value)) {
274+
quickpick.items = [
275+
RefQuickPickItem.create(value, repos.path, true, { alwaysShow: true, ref: false, icon: false }),
276+
];
277+
return true;
278+
}
279+
272280
if (!(await Container.git.validateReference(repos.path, value))) {
273281
if (inRefMode) {
274282
quickpick.items = [
@@ -510,13 +518,15 @@ export async function* pickBranchOrTagStep<
510518
titleContext,
511519
value,
512520
additionalButtons,
521+
ranges,
513522
}: {
514523
filter?: { branches?: (b: GitBranch) => boolean; tags?: (t: GitTag) => boolean };
515524
picked: string | string[] | undefined;
516525
placeholder: string | ((context: Context) => string);
517526
titleContext?: string;
518527
value: string | undefined;
519528
additionalButtons?: QuickInputButton[];
529+
ranges?: boolean;
520530
},
521531
): StepResultGenerator<GitReference> {
522532
context.showTags = true;
@@ -606,7 +616,7 @@ export async function* pickBranchOrTagStep<
606616
void GitActions.Commit.reveal(item, { select: true, focus: false, expand: true });
607617
}
608618
},
609-
onValidateValue: getValidateGitReferenceFn(state.repo),
619+
onValidateValue: getValidateGitReferenceFn(state.repo, { ranges: ranges }),
610620
});
611621
const selection: StepSelection<typeof step> = yield step;
612622
return QuickCommand.canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break;

src/quickpicks/gitQuickPickItems.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,19 @@ export namespace RefQuickPickItem {
273273

274274
const gitRef = GitReference.create(ref, repoPath);
275275

276+
if (GitRevision.isRange(ref)) {
277+
return {
278+
label: `Range ${gitRef.name}`,
279+
description: '',
280+
alwaysShow: options.alwaysShow,
281+
picked: picked,
282+
item: gitRef,
283+
current: false,
284+
ref: ref,
285+
remote: false,
286+
};
287+
}
288+
276289
const item: RefQuickPickItem = {
277290
label: `Commit ${gitRef.name}`,
278291
description: options.ref ? `$(git-commit) ${ref}` : '',

0 commit comments

Comments
 (0)