diff --git a/src/commands/git/branch.ts b/src/commands/git/branch.ts index c61c796..3ff7692 100644 --- a/src/commands/git/branch.ts +++ b/src/commands/git/branch.ts @@ -256,6 +256,7 @@ export class BranchGitCommand extends QuickCommand { placeholder: context => `Choose a branch${context.showTags ? ' or tag' : ''} to create the new branch from`, picked: state.reference?.ref ?? (await state.repo.getBranch())?.ref, + titleContext: ' from', value: GitReference.isRevision(state.reference) ? state.reference.ref : undefined, }); // Always break on the first step (so we will go back) @@ -267,7 +268,11 @@ 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 ${GitReference.toString(state.reference, { capitalize: true, icon: false })}`, + titleContext: ` from ${GitReference.toString(state.reference, { + capitalize: true, + icon: false, + label: state.reference.refType !== 'branch', + })}`, value: state.name ?? GitReference.getNameWithoutRemote(state.reference), }); if (result === StepResult.Break) continue; diff --git a/src/git/models/models.ts b/src/git/models/models.ts index 77ffe3b..7b07701 100644 --- a/src/git/models/models.ts +++ b/src/git/models/models.ts @@ -321,7 +321,7 @@ export namespace GitReference { } } - return options.capitalize && options.expand + return options.capitalize && options.expand && options.label !== false ? `${result[0].toLocaleUpperCase()}${result.substring(1)}` : result; } diff --git a/src/views/viewCommands.ts b/src/views/viewCommands.ts index 79de8ed..f7aae07 100644 --- a/src/views/viewCommands.ts +++ b/src/views/viewCommands.ts @@ -280,8 +280,13 @@ export class ViewCommands { } @debug() - private createBranch(node?: ViewRefNode | BranchesNode) { - return GitActions.Branch.create(node?.repoPath, node instanceof ViewRefNode ? node?.ref : undefined); + private async createBranch(node?: ViewRefNode | BranchesNode) { + let from = node instanceof ViewRefNode ? node?.ref : undefined; + if (from == null) { + const branch = await Container.git.getBranch(node?.repoPath ?? (await Container.git.getActiveRepoPath())); + from = branch; + } + return GitActions.Branch.create(node?.repoPath, from); } @debug()