Removed one TODO -- better cloning of all branches, origin/master setup automatically, and fake teamwork anywhere

This commit is contained in:
Peter Cottle 2013-07-04 18:09:53 -07:00
parent 11a3062797
commit e382004a55
6 changed files with 84 additions and 42 deletions

View file

@ -7388,12 +7388,15 @@ GitEngine.prototype.makeOrigin = function(treeString) {
// locally, so we have to go up the chain. for now we assume the master on
// origin is at least present.
var originTree = JSON.parse(unescape(treeString));
var originMasterTarget = originTree.branches.master.target;
var originMaster = this.makeBranch(
'o/master',
this.getCommitFromRef(originMasterTarget)
// make an origin branch for each branch mentioned in the tree
_.each(originTree.branches, function(branchJSON, branchName) {
var originTarget = branchJSON.target;
var originBranch = this.makeBranch(
'o/' + branchName,
this.getCommitFromRef(originTarget)
);
originMaster.set('remote', true);
originBranch.set('remote', true);
}, this);
};
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
@ -8240,7 +8243,7 @@ GitEngine.prototype.pullFinishWithMerge = function(
GitEngine.prototype.cloneStarter = function() {
this.acceptNoGeneralArgs();
this.makeOrigin(this.printTree(this.exportTreeForBranch('master')));
this.makeOrigin(this.printTree());
};
GitEngine.prototype.fakeTeamworkStarter = function() {
@ -8250,15 +8253,25 @@ GitEngine.prototype.fakeTeamworkStarter = function() {
});
}
this.validateArgBounds(this.generalArgs, 0, 1);
var numToMake = this.generalArgs[0] || 1;
this.fakeTeamwork(numToMake);
this.validateArgBounds(this.generalArgs, 0, 2);
var branch = this.generalArgs[0] || 'master';
var numToMake = this.generalArgs[1] || 1;
// make sure its a branch and exists
var destBranch = this.origin.resolveID(branch);
if (destBranch.get('type') !== 'branch') {
throw new GitError({
msg: intl.str('git-error-options')
});
}
this.fakeTeamwork(numToMake, branch);
};
GitEngine.prototype.fakeTeamwork = function(numToMake) {
GitEngine.prototype.fakeTeamwork = function(numToMake, branch) {
var makeOriginCommit = _.bind(function() {
var id = this.getUniqueID();
return this.origin.receiveTeamwork(id, this.animationQueue);
return this.origin.receiveTeamwork(id, branch, this.animationQueue);
}, this);
var chainStep = _.bind(function() {
@ -8281,7 +8294,8 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
this.animationQueue.thenFinish(chain, deferred);
};
GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
GitEngine.prototype.receiveTeamwork = function(id, branch, animationQueue) {
this.checkout(this.resolveID(branch));
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
this.setTargetLocation(this.HEAD, newCommit);
@ -23780,12 +23794,15 @@ GitEngine.prototype.makeOrigin = function(treeString) {
// locally, so we have to go up the chain. for now we assume the master on
// origin is at least present.
var originTree = JSON.parse(unescape(treeString));
var originMasterTarget = originTree.branches.master.target;
var originMaster = this.makeBranch(
'o/master',
this.getCommitFromRef(originMasterTarget)
// make an origin branch for each branch mentioned in the tree
_.each(originTree.branches, function(branchJSON, branchName) {
var originTarget = branchJSON.target;
var originBranch = this.makeBranch(
'o/' + branchName,
this.getCommitFromRef(originTarget)
);
originMaster.set('remote', true);
originBranch.set('remote', true);
}, this);
};
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
@ -24632,7 +24649,7 @@ GitEngine.prototype.pullFinishWithMerge = function(
GitEngine.prototype.cloneStarter = function() {
this.acceptNoGeneralArgs();
this.makeOrigin(this.printTree(this.exportTreeForBranch('master')));
this.makeOrigin(this.printTree());
};
GitEngine.prototype.fakeTeamworkStarter = function() {
@ -24642,15 +24659,25 @@ GitEngine.prototype.fakeTeamworkStarter = function() {
});
}
this.validateArgBounds(this.generalArgs, 0, 1);
var numToMake = this.generalArgs[0] || 1;
this.fakeTeamwork(numToMake);
this.validateArgBounds(this.generalArgs, 0, 2);
var branch = this.generalArgs[0] || 'master';
var numToMake = this.generalArgs[1] || 1;
// make sure its a branch and exists
var destBranch = this.origin.resolveID(branch);
if (destBranch.get('type') !== 'branch') {
throw new GitError({
msg: intl.str('git-error-options')
});
}
this.fakeTeamwork(numToMake, branch);
};
GitEngine.prototype.fakeTeamwork = function(numToMake) {
GitEngine.prototype.fakeTeamwork = function(numToMake, branch) {
var makeOriginCommit = _.bind(function() {
var id = this.getUniqueID();
return this.origin.receiveTeamwork(id, this.animationQueue);
return this.origin.receiveTeamwork(id, branch, this.animationQueue);
}, this);
var chainStep = _.bind(function() {
@ -24673,7 +24700,8 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
this.animationQueue.thenFinish(chain, deferred);
};
GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
GitEngine.prototype.receiveTeamwork = function(id, branch, animationQueue) {
this.checkout(this.resolveID(branch));
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
this.setTargetLocation(this.HEAD, newCommit);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
build/bundle.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -434,7 +434,7 @@
For a much easier time perusing the source, see the individual files at:
https://github.com/pcottle/learnGitBranching
-->
<script src="build/bundle.min.ef516df2.js"></script>
<script src="build/bundle.min.141ecc64.js"></script>
<!-- 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

View file

@ -269,12 +269,15 @@ GitEngine.prototype.makeOrigin = function(treeString) {
// locally, so we have to go up the chain. for now we assume the master on
// origin is at least present.
var originTree = JSON.parse(unescape(treeString));
var originMasterTarget = originTree.branches.master.target;
var originMaster = this.makeBranch(
'o/master',
this.getCommitFromRef(originMasterTarget)
// make an origin branch for each branch mentioned in the tree
_.each(originTree.branches, function(branchJSON, branchName) {
var originTarget = branchJSON.target;
var originBranch = this.makeBranch(
'o/' + branchName,
this.getCommitFromRef(originTarget)
);
originMaster.set('remote', true);
originBranch.set('remote', true);
}, this);
};
GitEngine.prototype.getOrMakeRecursive = function(tree, createdSoFar, objID) {
@ -1121,7 +1124,7 @@ GitEngine.prototype.pullFinishWithMerge = function(
GitEngine.prototype.cloneStarter = function() {
this.acceptNoGeneralArgs();
this.makeOrigin(this.printTree(this.exportTreeForBranch('master')));
this.makeOrigin(this.printTree());
};
GitEngine.prototype.fakeTeamworkStarter = function() {
@ -1131,15 +1134,25 @@ GitEngine.prototype.fakeTeamworkStarter = function() {
});
}
this.validateArgBounds(this.generalArgs, 0, 1);
var numToMake = this.generalArgs[0] || 1;
this.fakeTeamwork(numToMake);
this.validateArgBounds(this.generalArgs, 0, 2);
var branch = this.generalArgs[0] || 'master';
var numToMake = this.generalArgs[1] || 1;
// make sure its a branch and exists
var destBranch = this.origin.resolveID(branch);
if (destBranch.get('type') !== 'branch') {
throw new GitError({
msg: intl.str('git-error-options')
});
}
this.fakeTeamwork(numToMake, branch);
};
GitEngine.prototype.fakeTeamwork = function(numToMake) {
GitEngine.prototype.fakeTeamwork = function(numToMake, branch) {
var makeOriginCommit = _.bind(function() {
var id = this.getUniqueID();
return this.origin.receiveTeamwork(id, this.animationQueue);
return this.origin.receiveTeamwork(id, branch, this.animationQueue);
}, this);
var chainStep = _.bind(function() {
@ -1162,7 +1175,8 @@ GitEngine.prototype.fakeTeamwork = function(numToMake) {
this.animationQueue.thenFinish(chain, deferred);
};
GitEngine.prototype.receiveTeamwork = function(id, animationQueue) {
GitEngine.prototype.receiveTeamwork = function(id, branch, animationQueue) {
this.checkout(this.resolveID(branch));
var newCommit = this.makeCommit([this.getCommitFromRef('HEAD')], id);
this.setTargetLocation(this.HEAD, newCommit);