mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 08:28:50 +02:00
Add git switch --create
This commit is contained in:
parent
8a3dd90e35
commit
2edc86e9a0
2 changed files with 20 additions and 10 deletions
|
@ -923,23 +923,26 @@ var commandConfig = {
|
|||
regex: /^git +switch($|\s)/,
|
||||
options: [
|
||||
'-c',
|
||||
'--create',
|
||||
'-'
|
||||
],
|
||||
execute: function(engine, command) {
|
||||
var generalArgs = command.getGeneralArgs();
|
||||
var commandOptions = command.getOptionsMap();
|
||||
|
||||
var args = null;
|
||||
if (commandOptions['-c']) {
|
||||
// the user is really trying to just make a
|
||||
// branch and then switch to it. so first:
|
||||
args = commandOptions['-c'].concat(generalArgs);
|
||||
command.twoArgsImpliedHead(args, '-c');
|
||||
{
|
||||
let createOption = commandOptions['-c'] ? commandOptions['-c'] : commandOptions['--create'];
|
||||
if (createOption) {
|
||||
// the user is really trying to just make a
|
||||
// branch and then switch to it. so first:
|
||||
var args = createOption.concat(generalArgs)
|
||||
command.twoArgsImpliedHead(args, '-c');
|
||||
|
||||
var validId = engine.validateBranchName(args[0]);
|
||||
engine.branch(validId, args[1]);
|
||||
engine.checkout(validId);
|
||||
return;
|
||||
var validId = engine.validateBranchName(args[0]);
|
||||
engine.branch(validId, args[1]);
|
||||
engine.checkout(validId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandOptions['-']) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue