awesome have part of git push working

This commit is contained in:
Peter Cottle 2013-06-11 09:28:14 -07:00
parent 84f180e6a8
commit c7da989845
8 changed files with 336 additions and 42 deletions

View file

@ -5409,6 +5409,10 @@ require.define("/src/js/intl/strings.js",function(require,module,exports,__dirna
'__desc__': 'One of the error messages for git', '__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' 'en_US': 'Your origin branch is out of sync with the remote branch and fetch cannot be performed. try using --force'
}, },
'git-error-origin-push-no-ff': {
'__desc__': 'One of the error messages for git',
'en_US': 'The remote repository has diverged from your local repository, so uploading your changes is not a simple fast forward (and thus your push was rejected). Please pull down the new changes in the remote repository, incorporate them into this branch, and try again. You can do so with git pull or git pull --rebase'
},
'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'
@ -7772,21 +7776,12 @@ GitEngine.prototype.cherrypickStarter = function() {
* Origin stuff! * Origin stuff!
************************************/ ************************************/
GitEngine.prototype.fetchStarter = function() {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.fetch();
};
GitEngine.prototype.checkUpstreamOfSource = function( GitEngine.prototype.checkUpstreamOfSource = function(
target, target,
source, source,
targetBranch, targetBranch,
sourceBranch sourceBranch,
errorMsg
) { ) {
// here we are downloading some X number of commits from source onto // here we are downloading some X number of commits from source onto
// target. Hence target should be strictly upstream of source // target. Hence target should be strictly upstream of source
@ -7797,7 +7792,7 @@ GitEngine.prototype.checkUpstreamOfSource = function(
var targetLocationID = target.getCommitFromRef(targetBranch).get('id'); var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
if (!upstream[targetLocationID]) { if (!upstream[targetLocationID]) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-origin-fetch-no-ff') msg: errorMsg || intl.str('git-error-origin-fetch-no-ff')
}); });
} }
}; };
@ -7816,7 +7811,7 @@ GitEngine.prototype.getTargetGraphDifference = function(
var sourceTree = source.exportTree(); var sourceTree = source.exportTree();
var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')]; var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')];
if (this.refs[sourceStartCommitJSON.id]) { if (target.refs[sourceStartCommitJSON.id]) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-origin-fetch-uptodate') msg: intl.str('git-error-origin-fetch-uptodate')
}); });
@ -7851,6 +7846,107 @@ GitEngine.prototype.getTargetGraphDifference = function(
}); });
}; };
GitEngine.prototype.pushStarter = function(options) {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.push();
};
GitEngine.prototype.push = function(options) {
options = options || {};
var localBranch = this.refs['master'];
var remoteBranch = this.origin.refs['master'];
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
remoteBranch,
localBranch,
intl.str('git-error-origin-push-no-ff')
);
var commitsToMake = this.getTargetGraphDifference(
this.origin,
this,
remoteBranch,
localBranch
);
var makeCommit = _.bind(function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know
// the dependencies are there already
var parents = _.map(parentIDs, function(parentID) {
return this.origin.refs[parentID];
}, this);
return this.origin.makeCommit(parents, id);
}, this);
// now make the promise chain to make each commit
var chainStep = _.bind(function(id, parents) {
var newCommit = makeCommit(id, parents);
return AnimationFactory.playCommitBirthPromiseAnimation(
newCommit,
this.origin.gitVisuals
);
}, this);
var deferred = Q.defer();
var chain = deferred.promise;
_.each(commitsToMake, function(commitJSON) {
chain = chain.then(_.bind(function() {
return AnimationFactory.playHighlightPromiseAnimation(
this.refs[commitJSON.id],
remoteBranch
);
}, this));
chain = chain.then(function() {
return chainStep(
commitJSON.id,
commitJSON.parents
);
});
}, this);
chain = chain.then(_.bind(function() {
var localLocationID = localBranch.get('target').get('id');
var remoteCommit = this.origin.refs[localLocationID];
this.origin.setTargetLocation(remoteBranch, remoteCommit);
// unhighlight local
AnimationFactory.playRefreshAnimation(this.gitVisuals);
return AnimationFactory.playRefreshAnimation(this.origin.gitVisuals);
}, this));
// HAX HAX update o/master
chain = chain.then(_.bind(function() {
var localLocationID = localBranch.get('target').get('id');
var localCommit = this.refs[localLocationID];
// HAX HAX
this.setTargetLocation(this.refs['o/master'], localCommit);
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred);
}
};
GitEngine.prototype.fetchStarter = function() {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.fetch();
};
GitEngine.prototype.fetch = function(options) { GitEngine.prototype.fetch = function(options) {
options = options || {}; options = options || {};
var localBranch = this.refs['o/master']; var localBranch = this.refs['o/master'];
@ -13523,6 +13619,7 @@ var regexMap = {
'git fakeTeamwork': /^git +fakeTeamwork($|\s)/, 'git fakeTeamwork': /^git +fakeTeamwork($|\s)/,
'git fetch': /^git +fetch *?$/, 'git fetch': /^git +fetch *?$/,
'git pull': /^git +pull($|\s)/, 'git pull': /^git +pull($|\s)/,
'git push': /^git +push($|\s)/,
'git clone': /^git +clone *?$/ 'git clone': /^git +clone *?$/
}; };
@ -13615,6 +13712,7 @@ GitOptionParser.prototype.getMasterOptionMap = function() {
pull: { pull: {
'--rebase': false '--rebase': false
}, },
push: {},
fakeTeamwork: {} fakeTeamwork: {}
}; };
}; };
@ -22733,6 +22831,7 @@ var regexMap = {
'git fakeTeamwork': /^git +fakeTeamwork($|\s)/, 'git fakeTeamwork': /^git +fakeTeamwork($|\s)/,
'git fetch': /^git +fetch *?$/, 'git fetch': /^git +fetch *?$/,
'git pull': /^git +pull($|\s)/, 'git pull': /^git +pull($|\s)/,
'git push': /^git +push($|\s)/,
'git clone': /^git +clone *?$/ 'git clone': /^git +clone *?$/
}; };
@ -22825,6 +22924,7 @@ GitOptionParser.prototype.getMasterOptionMap = function() {
pull: { pull: {
'--rebase': false '--rebase': false
}, },
push: {},
fakeTeamwork: {} fakeTeamwork: {}
}; };
}; };
@ -23767,21 +23867,12 @@ GitEngine.prototype.cherrypickStarter = function() {
* Origin stuff! * Origin stuff!
************************************/ ************************************/
GitEngine.prototype.fetchStarter = function() {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.fetch();
};
GitEngine.prototype.checkUpstreamOfSource = function( GitEngine.prototype.checkUpstreamOfSource = function(
target, target,
source, source,
targetBranch, targetBranch,
sourceBranch sourceBranch,
errorMsg
) { ) {
// here we are downloading some X number of commits from source onto // here we are downloading some X number of commits from source onto
// target. Hence target should be strictly upstream of source // target. Hence target should be strictly upstream of source
@ -23792,7 +23883,7 @@ GitEngine.prototype.checkUpstreamOfSource = function(
var targetLocationID = target.getCommitFromRef(targetBranch).get('id'); var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
if (!upstream[targetLocationID]) { if (!upstream[targetLocationID]) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-origin-fetch-no-ff') msg: errorMsg || intl.str('git-error-origin-fetch-no-ff')
}); });
} }
}; };
@ -23811,7 +23902,7 @@ GitEngine.prototype.getTargetGraphDifference = function(
var sourceTree = source.exportTree(); var sourceTree = source.exportTree();
var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')]; var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')];
if (this.refs[sourceStartCommitJSON.id]) { if (target.refs[sourceStartCommitJSON.id]) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-origin-fetch-uptodate') msg: intl.str('git-error-origin-fetch-uptodate')
}); });
@ -23846,6 +23937,107 @@ GitEngine.prototype.getTargetGraphDifference = function(
}); });
}; };
GitEngine.prototype.pushStarter = function(options) {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.push();
};
GitEngine.prototype.push = function(options) {
options = options || {};
var localBranch = this.refs['master'];
var remoteBranch = this.origin.refs['master'];
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
remoteBranch,
localBranch,
intl.str('git-error-origin-push-no-ff')
);
var commitsToMake = this.getTargetGraphDifference(
this.origin,
this,
remoteBranch,
localBranch
);
var makeCommit = _.bind(function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know
// the dependencies are there already
var parents = _.map(parentIDs, function(parentID) {
return this.origin.refs[parentID];
}, this);
return this.origin.makeCommit(parents, id);
}, this);
// now make the promise chain to make each commit
var chainStep = _.bind(function(id, parents) {
var newCommit = makeCommit(id, parents);
return AnimationFactory.playCommitBirthPromiseAnimation(
newCommit,
this.origin.gitVisuals
);
}, this);
var deferred = Q.defer();
var chain = deferred.promise;
_.each(commitsToMake, function(commitJSON) {
chain = chain.then(_.bind(function() {
return AnimationFactory.playHighlightPromiseAnimation(
this.refs[commitJSON.id],
remoteBranch
);
}, this));
chain = chain.then(function() {
return chainStep(
commitJSON.id,
commitJSON.parents
);
});
}, this);
chain = chain.then(_.bind(function() {
var localLocationID = localBranch.get('target').get('id');
var remoteCommit = this.origin.refs[localLocationID];
this.origin.setTargetLocation(remoteBranch, remoteCommit);
// unhighlight local
AnimationFactory.playRefreshAnimation(this.gitVisuals);
return AnimationFactory.playRefreshAnimation(this.origin.gitVisuals);
}, this));
// HAX HAX update o/master
chain = chain.then(_.bind(function() {
var localLocationID = localBranch.get('target').get('id');
var localCommit = this.refs[localLocationID];
// HAX HAX
this.setTargetLocation(this.refs['o/master'], localCommit);
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred);
}
};
GitEngine.prototype.fetchStarter = function() {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.fetch();
};
GitEngine.prototype.fetch = function(options) { GitEngine.prototype.fetch = function(options) {
options = options || {}; options = options || {};
var localBranch = this.refs['o/master']; var localBranch = this.refs['o/master'];
@ -25816,6 +26008,10 @@ require.define("/src/js/intl/strings.js",function(require,module,exports,__dirna
'__desc__': 'One of the error messages for git', '__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' 'en_US': 'Your origin branch is out of sync with the remote branch and fetch cannot be performed. try using --force'
}, },
'git-error-origin-push-no-ff': {
'__desc__': 'One of the error messages for git',
'en_US': 'The remote repository has diverged from your local repository, so uploading your changes is not a simple fast forward (and thus your push was rejected). Please pull down the new changes in the remote repository, incorporate them into this branch, and try again. You can do so with git pull or git pull --rebase'
},
'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'

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

@ -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.701641cf.js"></script> <script src="build/bundle.min.2da41809.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

View file

@ -65,6 +65,7 @@ var regexMap = {
'git fakeTeamwork': /^git +fakeTeamwork($|\s)/, 'git fakeTeamwork': /^git +fakeTeamwork($|\s)/,
'git fetch': /^git +fetch *?$/, 'git fetch': /^git +fetch *?$/,
'git pull': /^git +pull($|\s)/, 'git pull': /^git +pull($|\s)/,
'git push': /^git +push($|\s)/,
'git clone': /^git +clone *?$/ 'git clone': /^git +clone *?$/
}; };
@ -157,6 +158,7 @@ GitOptionParser.prototype.getMasterOptionMap = function() {
pull: { pull: {
'--rebase': false '--rebase': false
}, },
push: {},
fakeTeamwork: {} fakeTeamwork: {}
}; };
}; };

View file

@ -730,21 +730,12 @@ GitEngine.prototype.cherrypickStarter = function() {
* Origin stuff! * Origin stuff!
************************************/ ************************************/
GitEngine.prototype.fetchStarter = function() {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.fetch();
};
GitEngine.prototype.checkUpstreamOfSource = function( GitEngine.prototype.checkUpstreamOfSource = function(
target, target,
source, source,
targetBranch, targetBranch,
sourceBranch sourceBranch,
errorMsg
) { ) {
// here we are downloading some X number of commits from source onto // here we are downloading some X number of commits from source onto
// target. Hence target should be strictly upstream of source // target. Hence target should be strictly upstream of source
@ -755,7 +746,7 @@ GitEngine.prototype.checkUpstreamOfSource = function(
var targetLocationID = target.getCommitFromRef(targetBranch).get('id'); var targetLocationID = target.getCommitFromRef(targetBranch).get('id');
if (!upstream[targetLocationID]) { if (!upstream[targetLocationID]) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-origin-fetch-no-ff') msg: errorMsg || intl.str('git-error-origin-fetch-no-ff')
}); });
} }
}; };
@ -774,7 +765,7 @@ GitEngine.prototype.getTargetGraphDifference = function(
var sourceTree = source.exportTree(); var sourceTree = source.exportTree();
var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')]; var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')];
if (this.refs[sourceStartCommitJSON.id]) { if (target.refs[sourceStartCommitJSON.id]) {
throw new GitError({ throw new GitError({
msg: intl.str('git-error-origin-fetch-uptodate') msg: intl.str('git-error-origin-fetch-uptodate')
}); });
@ -809,6 +800,107 @@ GitEngine.prototype.getTargetGraphDifference = function(
}); });
}; };
GitEngine.prototype.pushStarter = function(options) {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.push();
};
GitEngine.prototype.push = function(options) {
options = options || {};
var localBranch = this.refs['master'];
var remoteBranch = this.origin.refs['master'];
// first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource(
this,
this.origin,
remoteBranch,
localBranch,
intl.str('git-error-origin-push-no-ff')
);
var commitsToMake = this.getTargetGraphDifference(
this.origin,
this,
remoteBranch,
localBranch
);
var makeCommit = _.bind(function(id, parentIDs) {
// need to get the parents first. since we order by depth, we know
// the dependencies are there already
var parents = _.map(parentIDs, function(parentID) {
return this.origin.refs[parentID];
}, this);
return this.origin.makeCommit(parents, id);
}, this);
// now make the promise chain to make each commit
var chainStep = _.bind(function(id, parents) {
var newCommit = makeCommit(id, parents);
return AnimationFactory.playCommitBirthPromiseAnimation(
newCommit,
this.origin.gitVisuals
);
}, this);
var deferred = Q.defer();
var chain = deferred.promise;
_.each(commitsToMake, function(commitJSON) {
chain = chain.then(_.bind(function() {
return AnimationFactory.playHighlightPromiseAnimation(
this.refs[commitJSON.id],
remoteBranch
);
}, this));
chain = chain.then(function() {
return chainStep(
commitJSON.id,
commitJSON.parents
);
});
}, this);
chain = chain.then(_.bind(function() {
var localLocationID = localBranch.get('target').get('id');
var remoteCommit = this.origin.refs[localLocationID];
this.origin.setTargetLocation(remoteBranch, remoteCommit);
// unhighlight local
AnimationFactory.playRefreshAnimation(this.gitVisuals);
return AnimationFactory.playRefreshAnimation(this.origin.gitVisuals);
}, this));
// HAX HAX update o/master
chain = chain.then(_.bind(function() {
var localLocationID = localBranch.get('target').get('id');
var localCommit = this.refs[localLocationID];
// HAX HAX
this.setTargetLocation(this.refs['o/master'], localCommit);
return AnimationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
if (!options.dontResolvePromise) {
this.animationQueue.thenFinish(chain, deferred);
}
};
GitEngine.prototype.fetchStarter = function() {
if (!this.hasOrigin()) {
throw new GitError({
msg: intl.str('git-error-origin-required')
});
}
this.acceptNoGeneralArgs();
this.fetch();
};
GitEngine.prototype.fetch = function(options) { GitEngine.prototype.fetch = function(options) {
options = options || {}; options = options || {};
var localBranch = this.refs['o/master']; var localBranch = this.refs['o/master'];

View file

@ -60,6 +60,10 @@ exports.strings = {
'__desc__': 'One of the error messages for git', '__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' 'en_US': 'Your origin branch is out of sync with the remote branch and fetch cannot be performed. try using --force'
}, },
'git-error-origin-push-no-ff': {
'__desc__': 'One of the error messages for git',
'en_US': 'The remote repository has diverged from your local repository, so uploading your changes is not a simple fast forward (and thus your push was rejected). Please pull down the new changes in the remote repository, incorporate them into this branch, and try again. You can do so with git pull or git pull --rebase'
},
'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'