Selaa lähdekoodia

Clarifies create branch "from" a bit better

Also defaults view action to use the current branch
main
Eric Amodio 3 vuotta sitten
vanhempi
commit
00c51b16a7
3 muutettua tiedostoa jossa 14 lisäystä ja 4 poistoa
  1. +6
    -1
      src/commands/git/branch.ts
  2. +1
    -1
      src/git/models/models.ts
  3. +7
    -2
      src/views/viewCommands.ts

+ 6
- 1
src/commands/git/branch.ts Näytä tiedosto

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

+ 1
- 1
src/git/models/models.ts Näytä tiedosto

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

+ 7
- 2
src/views/viewCommands.ts Näytä tiedosto

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

Ladataan…
Peruuta
Tallenna