Skip to content

Commit

Permalink
Merge pull request kahole#290 from bezbac/develop
Browse files Browse the repository at this point in the history
Adds support for `magit-branch-spinoff`
  • Loading branch information
kahole authored Mar 25, 2024
2 parents d02ed6f + 1a323ef commit cce3727
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/commands/branchingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const branchingCommands = [
{ label: 'c', description: 'Checkout new branch', action: checkoutNewBranch },
// { label: "w", description: "Checkout new worktree", action: checkout },
// { label: "y", description: "Checkout pull-request", action: checkout },
// { label: "s", description: "Create new spin-off", action: createNewSpinoff },
{ label: 's', description: 'Create new spin-off', action: createNewSpinoff },
{ label: 'n', description: 'Create new branch', action: createNewBranch },
// { label: "W", description: "Create new worktree", action: checkout },
// { label: "Y", description: "Create from pull-request", action: checkout },
Expand Down Expand Up @@ -201,3 +201,19 @@ async function _createBranch({ repository }: MenuState, checkout: boolean) {
}
}
}

async function createNewSpinoff({ repository }: MenuState) {
const newBranchName = await window.showInputBox({
prompt: 'Name for new branch',
});

if (newBranchName && newBranchName.length > 0) {
const args = ['checkout', '-B', newBranchName];
return gitRun(repository.gitRepository, args);
} else {
window.setStatusBarMessage(
'No name given for new branch',
Constants.StatusMessageDisplayTimeout
);
}
}

0 comments on commit cce3727

Please sign in to comment.