diff --git a/CHANGELOG.md b/CHANGELOG.md index fcea096..23e9fd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Added + +- Adds ability to enter reference ranges (e.g. `main...release/1.0`) to the _Git Command Palette_'s _history_ command + ### Fixed - Fixes [#1148](https://github.com/eamodio/vscode-gitlens/issues/1148) - Follow renames on File History cannot load more history diff --git a/src/commands/git/log.ts b/src/commands/git/log.ts index 92d09db..0085c5c 100644 --- a/src/commands/git/log.ts +++ b/src/commands/git/log.ts @@ -115,6 +115,7 @@ export class LogGitCommand extends QuickCommand<State> { placeholder: 'Choose a branch or tag to show its commit history', picked: context.selectedBranchOrTag?.ref, value: context.selectedBranchOrTag == null ? state.reference?.ref : undefined, + ranges: true, }); if (result === StepResult.Break) { // If we skipped the previous step, make sure we back up past it diff --git a/src/commands/quickCommand.steps.ts b/src/commands/quickCommand.steps.ts index a60f7b7..50c6977 100644 --- a/src/commands/quickCommand.steps.ts +++ b/src/commands/quickCommand.steps.ts @@ -68,6 +68,7 @@ import { OpenChangedFilesCommandQuickPickItem, OpenRemoteResourceCommandQuickPickItem, ReferencesQuickPickItem, + RefQuickPickItem, RepositoryQuickPickItem, RevealInSideBarQuickPickItem, SearchForCommitQuickPickItem, @@ -255,7 +256,7 @@ export async function getBranchesAndOrTags( ]); } -export function getValidateGitReferenceFn(repos: Repository | Repository[]) { +export function getValidateGitReferenceFn(repos: Repository | Repository[], options?: { ranges?: boolean }) { return async (quickpick: QuickPick<any>, value: string) => { let inRefMode = false; if (value.startsWith('#')) { @@ -269,6 +270,13 @@ export function getValidateGitReferenceFn(repos: Repository | Repository[]) { repos = repos[0]; } + if (inRefMode && options?.ranges && GitRevision.isRange(value)) { + quickpick.items = [ + RefQuickPickItem.create(value, repos.path, true, { alwaysShow: true, ref: false, icon: false }), + ]; + return true; + } + if (!(await Container.git.validateReference(repos.path, value))) { if (inRefMode) { quickpick.items = [ @@ -510,6 +518,7 @@ export async function* pickBranchOrTagStep< titleContext, value, additionalButtons, + ranges, }: { filter?: { branches?: (b: GitBranch) => boolean; tags?: (t: GitTag) => boolean }; picked: string | string[] | undefined; @@ -517,6 +526,7 @@ export async function* pickBranchOrTagStep< titleContext?: string; value: string | undefined; additionalButtons?: QuickInputButton[]; + ranges?: boolean; }, ): StepResultGenerator<GitReference> { context.showTags = true; @@ -606,7 +616,7 @@ export async function* pickBranchOrTagStep< void GitActions.Commit.reveal(item, { select: true, focus: false, expand: true }); } }, - onValidateValue: getValidateGitReferenceFn(state.repo), + onValidateValue: getValidateGitReferenceFn(state.repo, { ranges: ranges }), }); const selection: StepSelection<typeof step> = yield step; return QuickCommand.canPickStepContinue(step, state, selection) ? selection[0].item : StepResult.Break; diff --git a/src/quickpicks/gitQuickPickItems.ts b/src/quickpicks/gitQuickPickItems.ts index 8ebab91..1fed7f7 100644 --- a/src/quickpicks/gitQuickPickItems.ts +++ b/src/quickpicks/gitQuickPickItems.ts @@ -273,6 +273,19 @@ export namespace RefQuickPickItem { const gitRef = GitReference.create(ref, repoPath); + if (GitRevision.isRange(ref)) { + return { + label: `Range ${gitRef.name}`, + description: '', + alwaysShow: options.alwaysShow, + picked: picked, + item: gitRef, + current: false, + ref: ref, + remote: false, + }; + } + const item: RefQuickPickItem = { label: `Commit ${gitRef.name}`, description: options.ref ? `$(git-commit) ${ref}` : '',