Browse Source

Adds ref range input into history/log git command

main
Eric Amodio 4 years ago
parent
commit
281249c589
4 changed files with 30 additions and 2 deletions
  1. +4
    -0
      CHANGELOG.md
  2. +1
    -0
      src/commands/git/log.ts
  3. +12
    -2
      src/commands/quickCommand.steps.ts
  4. +13
    -0
      src/quickpicks/gitQuickPickItems.ts

+ 4
- 0
CHANGELOG.md View File

@ -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

+ 1
- 0
src/commands/git/log.ts View File

@ -115,6 +115,7 @@ export class LogGitCommand extends QuickCommand {
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

+ 12
- 2
src/commands/quickCommand.steps.ts View File

@ -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;

+ 13
- 0
src/quickpicks/gitQuickPickItems.ts View File

@ -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}` : '',

Loading…
Cancel
Save