mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 16:08:34 +02:00
WIP working on get target graph difference
This commit is contained in:
parent
6e75e04daf
commit
6cc0b182cc
7 changed files with 115 additions and 106 deletions
114
build/bundle.js
114
build/bundle.js
|
@ -7774,16 +7774,35 @@ GitEngine.prototype.fetchStarter = function() {
|
||||||
this.fetch();
|
this.fetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.checkUpstreamOfSource = function(
|
||||||
|
target,
|
||||||
|
source,
|
||||||
|
targetBranch,
|
||||||
|
sourceBranch
|
||||||
|
) {
|
||||||
|
// here we are downloading some X number of commits from source onto
|
||||||
|
// target. Hence target should be strictly upstream of source
|
||||||
|
|
||||||
|
// lets first get the upstream set from source's dest branch
|
||||||
|
var upstream = source.getUpstreamSet(sourceBranch);
|
||||||
|
|
||||||
|
var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
|
||||||
|
if (!upstream[targetLocationID]) {
|
||||||
|
throw new GitError({
|
||||||
|
msg: 'no no'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GitEngine.prototype.fetch = function() {
|
GitEngine.prototype.fetch = function() {
|
||||||
// ok so we essentially are always in "-force" mode, since we always assume
|
// first check if this is even allowed by checking the sync between
|
||||||
// the origin commits are downstream of where we are. Here is the outline:
|
this.checkUpstreamOfSource(
|
||||||
//
|
this,
|
||||||
// first we get the commits we need by exporting the origin tree and
|
this.origin,
|
||||||
// walking upwards until we hit the upstream set defined by origin/master.
|
this.refs['o/master'],
|
||||||
//
|
this.origin.refs['master']
|
||||||
// then we simply set the target of o/master to the target of master on
|
);
|
||||||
// the origin branch
|
|
||||||
// TODO -- we cant abuse this anymore if we want to animate it :(
|
|
||||||
var oldCommits = this.exportTree().commits;
|
var oldCommits = this.exportTree().commits;
|
||||||
// HAX HAX omg we will abuse our tree instantiation here :D
|
// HAX HAX omg we will abuse our tree instantiation here :D
|
||||||
var originTree = this.origin.exportTree();
|
var originTree = this.origin.exportTree();
|
||||||
|
@ -8607,7 +8626,7 @@ GitEngine.prototype.checkout = function(idOrTarget) {
|
||||||
var type = target.get('type');
|
var type = target.get('type');
|
||||||
// check if this is an origin branch, and if so go to the commit referenced
|
// check if this is an origin branch, and if so go to the commit referenced
|
||||||
if (type === 'branch' && target.getIsRemote()) {
|
if (type === 'branch' && target.getIsRemote()) {
|
||||||
target = this.getCommitFromRef(target.get('id'));
|
//target = this.getCommitFromRef(target.get('id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type !== 'branch' && type !== 'commit') {
|
if (type !== 'branch' && type !== 'commit') {
|
||||||
|
@ -9407,7 +9426,9 @@ TreeCompare.dispatchFromLevel = function(levelBlob, treeToCompare) {
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
||||||
switch(true) {
|
var getAroundLintTrue = true;
|
||||||
|
// i actually prefer this to else if
|
||||||
|
switch (getAroundLintTrue) {
|
||||||
case !!levelBlob.compareOnlyMaster:
|
case !!levelBlob.compareOnlyMaster:
|
||||||
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
|
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
|
||||||
case !!levelBlob.compareOnlyBranches:
|
case !!levelBlob.compareOnlyBranches:
|
||||||
|
@ -16639,18 +16660,8 @@ var VisBranch = VisBase.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
shouldOffsetY: function() {
|
|
||||||
return this.gitEngine.getBranches().length > 1;
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshOffset: function() {
|
refreshOffset: function() {
|
||||||
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
|
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
|
||||||
if (!this.shouldOffsetY()) {
|
|
||||||
this.set('offsetY', 0);
|
|
||||||
this.set('offsetX', baseOffsetX);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var offsetY = 33;
|
var offsetY = 33;
|
||||||
var deltaX = 10;
|
var deltaX = 10;
|
||||||
if (this.get('flip') === 1) {
|
if (this.get('flip') === 1) {
|
||||||
|
@ -16663,9 +16674,7 @@ var VisBranch = VisBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getArrowTransform: function() {
|
getArrowTransform: function() {
|
||||||
if (!this.shouldOffsetY()) {
|
if (this.get('flip') === 1) {
|
||||||
return '';
|
|
||||||
} else if (this.get('flip') === 1) {
|
|
||||||
return 't-2,-20R-35';
|
return 't-2,-20R-35';
|
||||||
} else {
|
} else {
|
||||||
return 't2,20R-35';
|
return 't2,20R-35';
|
||||||
|
@ -23620,16 +23629,35 @@ GitEngine.prototype.fetchStarter = function() {
|
||||||
this.fetch();
|
this.fetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.checkUpstreamOfSource = function(
|
||||||
|
target,
|
||||||
|
source,
|
||||||
|
targetBranch,
|
||||||
|
sourceBranch
|
||||||
|
) {
|
||||||
|
// here we are downloading some X number of commits from source onto
|
||||||
|
// target. Hence target should be strictly upstream of source
|
||||||
|
|
||||||
|
// lets first get the upstream set from source's dest branch
|
||||||
|
var upstream = source.getUpstreamSet(sourceBranch);
|
||||||
|
|
||||||
|
var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
|
||||||
|
if (!upstream[targetLocationID]) {
|
||||||
|
throw new GitError({
|
||||||
|
msg: 'no no'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
GitEngine.prototype.fetch = function() {
|
GitEngine.prototype.fetch = function() {
|
||||||
// ok so we essentially are always in "-force" mode, since we always assume
|
// first check if this is even allowed by checking the sync between
|
||||||
// the origin commits are downstream of where we are. Here is the outline:
|
this.checkUpstreamOfSource(
|
||||||
//
|
this,
|
||||||
// first we get the commits we need by exporting the origin tree and
|
this.origin,
|
||||||
// walking upwards until we hit the upstream set defined by origin/master.
|
this.refs['o/master'],
|
||||||
//
|
this.origin.refs['master']
|
||||||
// then we simply set the target of o/master to the target of master on
|
);
|
||||||
// the origin branch
|
|
||||||
// TODO -- we cant abuse this anymore if we want to animate it :(
|
|
||||||
var oldCommits = this.exportTree().commits;
|
var oldCommits = this.exportTree().commits;
|
||||||
// HAX HAX omg we will abuse our tree instantiation here :D
|
// HAX HAX omg we will abuse our tree instantiation here :D
|
||||||
var originTree = this.origin.exportTree();
|
var originTree = this.origin.exportTree();
|
||||||
|
@ -24453,7 +24481,7 @@ GitEngine.prototype.checkout = function(idOrTarget) {
|
||||||
var type = target.get('type');
|
var type = target.get('type');
|
||||||
// check if this is an origin branch, and if so go to the commit referenced
|
// check if this is an origin branch, and if so go to the commit referenced
|
||||||
if (type === 'branch' && target.getIsRemote()) {
|
if (type === 'branch' && target.getIsRemote()) {
|
||||||
target = this.getCommitFromRef(target.get('id'));
|
//target = this.getCommitFromRef(target.get('id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type !== 'branch' && type !== 'commit') {
|
if (type !== 'branch' && type !== 'commit') {
|
||||||
|
@ -24960,7 +24988,9 @@ TreeCompare.dispatchFromLevel = function(levelBlob, treeToCompare) {
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
TreeCompare.dispatch = function(levelBlob, goalTreeString, treeToCompare) {
|
||||||
switch(true) {
|
var getAroundLintTrue = true;
|
||||||
|
// i actually prefer this to else if
|
||||||
|
switch (getAroundLintTrue) {
|
||||||
case !!levelBlob.compareOnlyMaster:
|
case !!levelBlob.compareOnlyMaster:
|
||||||
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
|
return TreeCompare.compareBranchWithinTrees(treeToCompare, goalTreeString, 'master');
|
||||||
case !!levelBlob.compareOnlyBranches:
|
case !!levelBlob.compareOnlyBranches:
|
||||||
|
@ -32539,18 +32569,8 @@ var VisBranch = VisBase.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
shouldOffsetY: function() {
|
|
||||||
return this.gitEngine.getBranches().length > 1;
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshOffset: function() {
|
refreshOffset: function() {
|
||||||
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
|
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
|
||||||
if (!this.shouldOffsetY()) {
|
|
||||||
this.set('offsetY', 0);
|
|
||||||
this.set('offsetX', baseOffsetX);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var offsetY = 33;
|
var offsetY = 33;
|
||||||
var deltaX = 10;
|
var deltaX = 10;
|
||||||
if (this.get('flip') === 1) {
|
if (this.get('flip') === 1) {
|
||||||
|
@ -32563,9 +32583,7 @@ var VisBranch = VisBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getArrowTransform: function() {
|
getArrowTransform: function() {
|
||||||
if (!this.shouldOffsetY()) {
|
if (this.get('flip') === 1) {
|
||||||
return '';
|
|
||||||
} else if (this.get('flip') === 1) {
|
|
||||||
return 't-2,-20R-35';
|
return 't-2,-20R-35';
|
||||||
} else {
|
} else {
|
||||||
return 't2,20R-35';
|
return 't2,20R-35';
|
||||||
|
|
File diff suppressed because one or more lines are too long
1
build/bundle.min.js
vendored
1
build/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -426,7 +426,7 @@
|
||||||
For a much easier time perusing the source, see the individual files at:
|
For a much easier time perusing the source, see the individual files at:
|
||||||
https://github.com/pcottle/learnGitBranching
|
https://github.com/pcottle/learnGitBranching
|
||||||
-->
|
-->
|
||||||
<script src="build/bundle.min.565ccc81.js"></script>
|
<script src="build/bundle.js"></script>
|
||||||
|
|
||||||
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
<!-- The advantage of github pages: super-easy, simple, slick static hostic.
|
||||||
The downside? No raw logs to parse for analytics, so I have to include
|
The downside? No raw logs to parse for analytics, so I have to include
|
||||||
|
|
|
@ -740,51 +740,52 @@ GitEngine.prototype.fetchStarter = function() {
|
||||||
this.fetch();
|
this.fetch();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.checkUpstreamOfSource = function(
|
||||||
|
target,
|
||||||
|
source,
|
||||||
|
targetBranch,
|
||||||
|
sourceBranch
|
||||||
|
) {
|
||||||
|
// here we are downloading some X number of commits from source onto
|
||||||
|
// target. Hence target should be strictly upstream of source
|
||||||
|
|
||||||
|
// lets first get the upstream set from source's dest branch
|
||||||
|
var upstream = source.getUpstreamSet(sourceBranch);
|
||||||
|
|
||||||
|
var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
|
||||||
|
if (!upstream[targetLocationID]) {
|
||||||
|
throw new GitError({
|
||||||
|
msg: intl.str('git-error-origin-fetch-no-ff')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GitEngine.prototype.getTargetGraphDifference = function(
|
||||||
|
target,
|
||||||
|
targetBranch,
|
||||||
|
source,
|
||||||
|
sourceBranch
|
||||||
|
) = {
|
||||||
|
sourceBranch = source.resolveID(sourceBranch);
|
||||||
|
|
||||||
|
var targetSet = target.getUpstreamSet(targetBranch);
|
||||||
|
var sourceTree = source.exportTree();
|
||||||
|
var startCommit = sourceTree.commits[
|
||||||
|
};
|
||||||
|
|
||||||
GitEngine.prototype.fetch = function() {
|
GitEngine.prototype.fetch = function() {
|
||||||
// ok so we essentially are always in "-force" mode, since we always assume
|
// first check if this is even allowed by checking the sync between
|
||||||
// the origin commits are downstream of where we are. Here is the outline:
|
this.checkUpstreamOfSource(
|
||||||
//
|
this,
|
||||||
// first we get the commits we need by exporting the origin tree and
|
this.origin,
|
||||||
// walking upwards until we hit the upstream set defined by origin/master.
|
this.refs['o/master'],
|
||||||
//
|
this.origin.refs['master']
|
||||||
// then we simply set the target of o/master to the target of master on
|
);
|
||||||
// the origin branch
|
|
||||||
// TODO -- we cant abuse this anymore if we want to animate it :(
|
|
||||||
var oldCommits = this.exportTree().commits;
|
|
||||||
// HAX HAX omg we will abuse our tree instantiation here :D
|
|
||||||
var originTree = this.origin.exportTree();
|
|
||||||
_.each(originTree.commits, function(commit, id) {
|
|
||||||
// if we have it, no worries
|
|
||||||
if (this.refs[id]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// go make it!
|
|
||||||
var downloadedCommit = this.getOrMakeRecursive(originTree, this.refs, id);
|
|
||||||
this.commitCollection.add(downloadedCommit);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
// since we now might have many commits more than before, lets
|
// then we get the difference in commits between these two graphs, ordered by
|
||||||
// check all the ones that didn't use to exist and make animations
|
// depth
|
||||||
var newCommits = this.exportTree().commits;
|
|
||||||
var commitsToAnimate = [];
|
|
||||||
_.each(newCommits, function(commit, id) {
|
|
||||||
if (oldCommits[id]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
commitsToAnimate.push(this.refs[id]);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
// now sort by id...
|
|
||||||
commitsToAnimate.sort(_.bind(this.idSortFunc, this));
|
|
||||||
|
|
||||||
_.each(commitsToAnimate, function(newCommit) {
|
|
||||||
AnimationFactory.genCommitBirthAnimation(
|
|
||||||
this.animationQueue,
|
|
||||||
newCommit,
|
|
||||||
this.gitVisuals
|
|
||||||
);
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
|
// this.commitCollection.add(downloadedCommit);
|
||||||
var originLocation = this.origin.exportTree().branches.master.target;
|
var originLocation = this.origin.exportTree().branches.master.target;
|
||||||
// yay! now we just set o/master and do a simple refresh
|
// yay! now we just set o/master and do a simple refresh
|
||||||
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);
|
this.setTargetLocation(this.refs['o/master'], this.refs[originLocation]);
|
||||||
|
|
|
@ -52,6 +52,10 @@ exports.strings = {
|
||||||
'en_US': 'Quick commit. Go Bears!',
|
'en_US': 'Quick commit. Go Bears!',
|
||||||
'zh_CN': '快速提交。上啊月熊!'
|
'zh_CN': '快速提交。上啊月熊!'
|
||||||
},
|
},
|
||||||
|
'git-error-origin-fetch-no-ff': {
|
||||||
|
'__desc__': 'One of the error messages for git',
|
||||||
|
'en_US': 'Your origin branch is out of sync with the remote branch and fetch cannot be performed. try using --force'
|
||||||
|
},
|
||||||
'git-error-remote-branch': {
|
'git-error-remote-branch': {
|
||||||
'__desc__': 'One of the error messages for git',
|
'__desc__': 'One of the error messages for git',
|
||||||
'en_US': 'You cannot execute that command on a remote branch'
|
'en_US': 'You cannot execute that command on a remote branch'
|
||||||
|
|
|
@ -102,18 +102,8 @@ var VisBranch = VisBase.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
shouldOffsetY: function() {
|
|
||||||
return this.gitEngine.getBranches().length > 1;
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshOffset: function() {
|
refreshOffset: function() {
|
||||||
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
|
var baseOffsetX = GRAPHICS.nodeRadius * 4.75;
|
||||||
if (!this.shouldOffsetY()) {
|
|
||||||
this.set('offsetY', 0);
|
|
||||||
this.set('offsetX', baseOffsetX);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var offsetY = 33;
|
var offsetY = 33;
|
||||||
var deltaX = 10;
|
var deltaX = 10;
|
||||||
if (this.get('flip') === 1) {
|
if (this.get('flip') === 1) {
|
||||||
|
@ -126,9 +116,7 @@ var VisBranch = VisBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getArrowTransform: function() {
|
getArrowTransform: function() {
|
||||||
if (!this.shouldOffsetY()) {
|
if (this.get('flip') === 1) {
|
||||||
return '';
|
|
||||||
} else if (this.get('flip') === 1) {
|
|
||||||
return 't-2,-20R-35';
|
return 't-2,-20R-35';
|
||||||
} else {
|
} else {
|
||||||
return 't2,20R-35';
|
return 't2,20R-35';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue