mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-07-08 05:34:27 +02:00
Modify GitEngine and add test
This commit is contained in:
parent
4471fc9595
commit
e7fcf25566
2 changed files with 16 additions and 2 deletions
|
@ -228,6 +228,13 @@ describe('Git', function() {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('if squash is specified, will always make a squash merge commit', function() {
|
||||||
|
return expectTreeAsync(
|
||||||
|
'git commit; go -b side HEAD~1; git commit; git merge main; go main; git merge side --squash',
|
||||||
|
'{"branches":{"main":{"target":"C5","id":"main","remoteTrackingBranchID":null},"side":{"target":"C4","id":"side","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"},"C3":{"parents":["C1"],"id":"C3"},"C4":{"parents":["C2","C3"],"id":"C4"},"C5":{"parents":["C2"],"id":"C5"}},"HEAD":{"target":"main","id":"HEAD"}}'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('makes a tag', function() {
|
it('makes a tag', function() {
|
||||||
return expectTreeAsync(
|
return expectTreeAsync(
|
||||||
'git tag v1',
|
'git tag v1',
|
||||||
|
|
|
@ -2474,7 +2474,7 @@ GitEngine.prototype.merge = function(targetSource, options) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isUpstreamOf(currentLocation, targetSource) && !options.noFF) {
|
if (this.isUpstreamOf(currentLocation, targetSource) && !options.noFF && !options.squash) {
|
||||||
// just set the target of this current location to the source
|
// just set the target of this current location to the source
|
||||||
this.setTargetLocation(currentLocation, this.getCommitFromRef(targetSource));
|
this.setTargetLocation(currentLocation, this.getCommitFromRef(targetSource));
|
||||||
// get fresh animation to happen
|
// get fresh animation to happen
|
||||||
|
@ -2496,8 +2496,15 @@ GitEngine.prototype.merge = function(targetSource, options) {
|
||||||
);
|
);
|
||||||
// since we specify parent 1 as the first parent, it is the "main" parent
|
// since we specify parent 1 as the first parent, it is the "main" parent
|
||||||
// and the node will be displayed below that branch / commit / whatever
|
// and the node will be displayed below that branch / commit / whatever
|
||||||
|
var commitParents = [parent1];
|
||||||
|
|
||||||
|
if (!options.squash) {
|
||||||
|
// a squash commit doesn't include the reference to the second parent
|
||||||
|
commitParents.push(parent2);
|
||||||
|
}
|
||||||
|
|
||||||
var mergeCommit = this.makeCommit(
|
var mergeCommit = this.makeCommit(
|
||||||
[parent1, parent2],
|
commitParents,
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
commitMessage: msg
|
commitMessage: msg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue