Skip to content

Commit

Permalink
Overhauls Switch and Worktree workflows
Browse files Browse the repository at this point in the history
  - Adds worktree creation to Switch command flow
  - Streamlines and simplifies worktree creation flow
Adds _GitLens: Checkout..._ command that maps to Switch
Renames _GitLens: Switch..._ command to _Switch to..._
  • Loading branch information
eamodio committed Jan 17, 2024
1 parent 5401f66 commit 9763a98
Show file tree
Hide file tree
Showing 15 changed files with 456 additions and 255 deletions.
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2816,8 +2816,7 @@
"type": "array",
"default": [
"fetch:command",
"stash-push:command",
"switch:command"
"stash-push:command"
],
"items": {
"type": "string",
Expand Down Expand Up @@ -5664,6 +5663,11 @@
"title": "Git Branch...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.checkout",
"title": "Git Checkout...",
"category": "GitLens"
},
{
"command": "gitlens.gitCommands.cherryPick",
"title": "Git Cherry Pick...",
Expand Down Expand Up @@ -5691,7 +5695,7 @@
},
{
"command": "gitlens.gitCommands.switch",
"title": "Git Switch...",
"title": "Git Switch to...",
"category": "GitLens"
},
{
Expand Down Expand Up @@ -9113,6 +9117,10 @@
"command": "gitlens.gitCommands.branch",
"when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
},
{
"command": "gitlens.gitCommands.checkout",
"when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
},
{
"command": "gitlens.gitCommands.cherryPick",
"when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders"
Expand Down
4 changes: 0 additions & 4 deletions src/commands/git/branch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ export class BranchGitCommand extends QuickCommand {

if (state.counter < 4 || state.name == null) {
const result = yield* inputBranchNameStep(state, context, {
placeholder: 'Please provide a name for the new branch',
titleContext: ` from ${getReferenceLabel(state.reference, {
capitalize: true,
icon: false,
Expand Down Expand Up @@ -523,9 +522,6 @@ export class BranchGitCommand extends QuickCommand {

if (state.counter < 4 || state.name == null) {
const result = yield* inputBranchNameStep(state, context, {
placeholder: `Please provide a new name for ${getReferenceLabel(state.reference, {
icon: false,
})}`,
titleContext: ` ${getReferenceLabel(state.reference, false)}`,
value: state.name ?? state.reference.name,
});
Expand Down
4 changes: 1 addition & 3 deletions src/commands/git/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ export class FetchGitCommand extends QuickCommand<State> {
);
} else {
const reposToFetch =
state.repos.length === 1
? `$(repo) ${state.repos[0].formattedName}`
: `${state.repos.length} repositories`;
state.repos.length === 1 ? `$(repo) ${state.repos[0].formattedName}` : `${state.repos.length} repos`;

step = createConfirmStep(
appendReposToTitle(`Confirm ${this.title}`, state, context, lastFetchedOn),
Expand Down
4 changes: 2 additions & 2 deletions src/commands/git/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ export class PullGitCommand extends QuickCommand<State> {
step = this.createConfirmStep(appendReposToTitle(`Confirm ${context.title}`, state, context), [
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will pull ${state.repos.length} repositories`,
detail: `Will pull ${state.repos.length} repos`,
}),
createFlagsQuickPickItem<Flags>(state.flags, ['--rebase'], {
label: `${this.title} with Rebase`,
description: '--rebase',
detail: `Will pull ${state.repos.length} repositories by rebasing`,
detail: `Will pull ${state.repos.length} repos by rebasing`,
}),
]);
} else if (isBranchReference(state.reference)) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/git/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class PushGitCommand extends QuickCommand<State> {
step = this.createConfirmStep(appendReposToTitle(`Confirm ${context.title}`, state, context), [
createFlagsQuickPickItem<Flags>(state.flags, [], {
label: this.title,
detail: `Will push ${state.repos.length} repositories`,
detail: `Will push ${state.repos.length} repos`,
}),
createFlagsQuickPickItem<Flags>(state.flags, ['--force'], {
label: `Force ${this.title}${
Expand All @@ -177,7 +177,7 @@ export class PushGitCommand extends QuickCommand<State> {
}`,
detail: `Will force push${
useForceIfIncludes ? ' (with lease and if includes)' : useForceWithLease ? ' (with lease)' : ''
} ${state.repos.length} repositories`,
} ${state.repos.length} repos`,
}),
]);
} else {
Expand Down
7 changes: 4 additions & 3 deletions src/commands/git/stash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { getSteps } from '../gitCommands.utils';
import type {
AsyncStepResultGenerator,
PartialStepState,
QuickPickStep,
StepGenerator,
StepResult,
StepResultGenerator,
Expand Down Expand Up @@ -624,7 +623,9 @@ export class StashGitCommand extends QuickCommand<State> {
baseFlags.push('--staged');
}

const confirmations: QuickPickItemOfT<PushFlags[]>[] = [];
type StepType = FlagsQuickPickItem<PushFlags>;

const confirmations: StepType[] = [];
if (state.uris?.length) {
if (state.flags.includes('--include-untracked')) {
baseFlags.push('--include-untracked');
Expand Down Expand Up @@ -684,7 +685,7 @@ export class StashGitCommand extends QuickCommand<State> {
}
}

const step: QuickPickStep<FlagsQuickPickItem<PushFlags>> = this.createConfirmStep(
const step = this.createConfirmStep(
appendReposToTitle(`Confirm ${context.title}`, state, context),
confirmations,
undefined,
Expand Down
Loading

0 comments on commit 9763a98

Please sign in to comment.