mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-08-17 16:21:06 +02:00
merge master
This commit is contained in:
commit
954fd4a0b2
2 changed files with 56 additions and 0 deletions
|
@ -60,6 +60,13 @@ describe('Git', function() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Switches', function() {
|
||||||
|
return expectTreeAsync(
|
||||||
|
'git switch -c side',
|
||||||
|
'{"branches":{"master":{"target":"C1","id":"master"},"side":{"target":"C1","id":"side"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"side","id":"HEAD"}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('Rebases', function() {
|
it('Rebases', function() {
|
||||||
return expectTreeAsync(
|
return expectTreeAsync(
|
||||||
'gc; git checkout -b side C1; gc; git rebase master',
|
'gc; git checkout -b side C1; gc; git rebase master',
|
||||||
|
@ -172,6 +179,13 @@ describe('Git', function() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('switches after a rebase ', function() {
|
||||||
|
return expectTreeAsync(
|
||||||
|
'git commit; git switch -c bugFix C1; git commit; git rebase master;git switch master',
|
||||||
|
'%7B%22branches%22%3A%7B%22master%22%3A%7B%22target%22%3A%22C2%22%2C%22id%22%3A%22master%22%7D%2C%22bugFix%22%3A%7B%22target%22%3A%22C3%27%22%2C%22id%22%3A%22bugFix%22%7D%7D%2C%22commits%22%3A%7B%22C0%22%3A%7B%22parents%22%3A%5B%5D%2C%22id%22%3A%22C0%22%2C%22rootCommit%22%3Atrue%7D%2C%22C1%22%3A%7B%22parents%22%3A%5B%22C0%22%5D%2C%22id%22%3A%22C1%22%7D%2C%22C2%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C2%22%7D%2C%22C3%22%3A%7B%22parents%22%3A%5B%22C1%22%5D%2C%22id%22%3A%22C3%22%7D%2C%22C3%27%22%3A%7B%22parents%22%3A%5B%22C2%22%5D%2C%22id%22%3A%22C3%27%22%7D%7D%2C%22HEAD%22%3A%7B%22target%22%3A%22master%22%2C%22id%22%3A%22HEAD%22%7D%7D'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('checks out after an interactive rebase', function() {
|
it('checks out after an interactive rebase', function() {
|
||||||
return expectTreeAsync(
|
return expectTreeAsync(
|
||||||
'git commit; git checkout -b bugFix C1; git commit; git rebase -i master --interactive-test;git checkout master',
|
'git commit; git checkout -b bugFix C1; git commit; git rebase -i master --interactive-test;git checkout master',
|
||||||
|
|
|
@ -855,6 +855,48 @@ var commandConfig = {
|
||||||
command.twoArgsImpliedHead(generalArgs);
|
command.twoArgsImpliedHead(generalArgs);
|
||||||
engine.tag(generalArgs[0], generalArgs[1]);
|
engine.tag(generalArgs[0], generalArgs[1]);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
switch: {
|
||||||
|
sc: /^(gsw|git sw)($|\s)/,
|
||||||
|
regex: /^git +switch($|\s)/,
|
||||||
|
options: [
|
||||||
|
'-c',
|
||||||
|
'-'
|
||||||
|
],
|
||||||
|
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');
|
||||||
|
|
||||||
|
var validId = engine.validateBranchName(args[0]);
|
||||||
|
engine.branch(validId, args[1]);
|
||||||
|
engine.checkout(validId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commandOptions['-']) {
|
||||||
|
// get the heads last location
|
||||||
|
var lastPlace = engine.HEAD.get('lastLastTarget');
|
||||||
|
if (!lastPlace) {
|
||||||
|
throw new GitError({
|
||||||
|
msg: intl.str('git-result-nothing')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
engine.HEAD.set('target', lastPlace);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
command.validateArgBounds(generalArgs, 1, 1);
|
||||||
|
|
||||||
|
engine.checkout(engine.crappyUnescape(generalArgs[0]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue