Skip to content

Commit

Permalink
Fixes #3650 prefills when it won't conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Oct 8, 2024
1 parent 2962c66 commit d481730
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

### Fixed

- Fixes [#3650](https://github.com/gitkraken/vscode-gitlens/issues/3650) - "Create & Switch to Local Branch" from remote branch no longer prefills local branch name to match remote branch name

## [15.6.0] - 2024-10-07

### Added
Expand Down
13 changes: 11 additions & 2 deletions src/commands/git/branch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { QuickInputButtons } from 'vscode';
import type { Container } from '../../container';
import type { GitBranchReference, GitReference } from '../../git/models/reference';
import { getReferenceLabel, isRevisionReference } from '../../git/models/reference';
import {
getNameWithoutRemote,
getReferenceLabel,
isBranchReference,
isRevisionReference,
} from '../../git/models/reference';
import { Repository } from '../../git/models/repository';
import type { GitWorktree } from '../../git/models/worktree';
import { getWorktreesByBranch } from '../../git/models/worktree';
Expand Down Expand Up @@ -361,7 +366,11 @@ export class BranchGitCommand extends QuickCommand {
icon: false,
label: state.reference.refType !== 'branch',
})}`,
value: state.name,
value:
state.name ?? // if it's a remote branch, pre-fill the name
(isBranchReference(state.reference) && state.reference.remote
? getNameWithoutRemote(state.reference)
: undefined),
});
if (result === StepResultBreak) continue;

Expand Down
13 changes: 11 additions & 2 deletions src/commands/git/switch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { ProgressLocation, window } from 'vscode';
import type { Container } from '../../container';
import type { GitReference } from '../../git/models/reference';
import { getReferenceLabel, getReferenceTypeLabel, isBranchReference } from '../../git/models/reference';
import {
getNameWithoutRemote,
getReferenceLabel,
getReferenceTypeLabel,
isBranchReference,
} from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import { createQuickPickSeparator } from '../../quickpicks/items/common';
Expand Down Expand Up @@ -295,7 +300,11 @@ export class SwitchGitCommand extends QuickCommand<State> {
icon: false,
label: state.reference.refType !== 'branch',
})}`,
value: state.createBranch,
value:
state.createBranch ?? // if it's a remote branch, pre-fill the name
(isBranchReference(state.reference) && state.reference.remote
? getNameWithoutRemote(state.reference)
: undefined),
});

this._canConfirmOverride = undefined;
Expand Down
11 changes: 9 additions & 2 deletions src/commands/git/tag.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { QuickInputButtons } from 'vscode';
import type { Container } from '../../container';
import type { GitReference, GitTagReference } from '../../git/models/reference';
import { getReferenceLabel, isRevisionReference } from '../../git/models/reference';
import {
getNameWithoutRemote,
getReferenceLabel,
isRevisionReference,
isTagReference,
} from '../../git/models/reference';
import type { Repository } from '../../git/models/repository';
import type { QuickPickItemOfT } from '../../quickpicks/items/common';
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
Expand Down Expand Up @@ -260,7 +265,9 @@ export class TagGitCommand extends QuickCommand<State> {
capitalize: true,
icon: false,
})}`,
value: state.name,
value:
state.name ?? // if it's not a tag, pre-fill the name
(!isTagReference(state.reference) ? getNameWithoutRemote(state.reference) : undefined),
});
if (result === StepResultBreak) continue;

Expand Down

0 comments on commit d481730

Please sign in to comment.