mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-20 21:35:42 +02:00
Add git switch --force-create
This commit is contained in:
parent
86bf7c7a71
commit
199f0219c4
2 changed files with 21 additions and 3 deletions
|
@ -105,6 +105,22 @@ describe('Git', function() {
|
||||||
'{"branches":{"main":{"target":"C1","id":"main"},"side":{"target":"C0","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"C0","id":"HEAD"}}'
|
'{"branches":{"main":{"target":"C1","id":"main"},"side":{"target":"C0","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"C0","id":"HEAD"}}'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('to a branch with --force-create option', function() {
|
||||||
|
return expectTreeAsync(
|
||||||
|
'git switch --force-create side',
|
||||||
|
'{"branches":{"main":{"target":"C1","id":"main"},"side":{"target":"C1","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"side","id":"HEAD"}}',
|
||||||
|
'{"branches":{"main":{"target":"C1","id":"main"},"side":{"target":"C0","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"main","id":"HEAD"}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('to a branch with --force-create option and given base branch', function() {
|
||||||
|
return expectTreeAsync(
|
||||||
|
'git switch --force-create side main',
|
||||||
|
'{"branches":{"main":{"target":"C1","id":"main"},"side":{"target":"C1","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"side","id":"HEAD"}}',
|
||||||
|
'{"branches":{"main":{"target":"C1","id":"main"},"side":{"target":"C0","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"C0","id":"HEAD"}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Rebases', function() {
|
it('Rebases', function() {
|
||||||
|
|
|
@ -925,6 +925,7 @@ var commandConfig = {
|
||||||
'-c',
|
'-c',
|
||||||
'--create',
|
'--create',
|
||||||
'-C',
|
'-C',
|
||||||
|
'--force-create',
|
||||||
'-'
|
'-'
|
||||||
],
|
],
|
||||||
execute: function(engine, command) {
|
execute: function(engine, command) {
|
||||||
|
@ -947,11 +948,12 @@ var commandConfig = {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let fc = '-C';
|
let sfc = '-C';
|
||||||
let fcOption = commandOptions[fc];
|
let lfc = '--force-create';
|
||||||
|
let fcOption = commandOptions[sfc] ? commandOptions[sfc] : commandOptions[lfc];
|
||||||
if (fcOption) {
|
if (fcOption) {
|
||||||
let args = fcOption.concat(generalArgs);
|
let args = fcOption.concat(generalArgs);
|
||||||
command.twoArgsImpliedHead(args, fc);
|
command.twoArgsImpliedHead(args, sfc);
|
||||||
|
|
||||||
let validId = engine.validateBranchName(args[0]);
|
let validId = engine.validateBranchName(args[0]);
|
||||||
engine.forceBranch(validId, args[1]);
|
engine.forceBranch(validId, args[1]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue