awesome fixed push for everythinggs

This commit is contained in:
Peter Cottle 2013-10-14 14:19:29 -07:00
parent 56e800220c
commit f543fa4485
3 changed files with 23 additions and 13 deletions

View file

@ -37,6 +37,13 @@ describe('Git Remotes', function() {
); );
}); });
it('pushes', function() {
expectTreeAsync(
'git clone; git commit; git push',
'{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C2","id":"o/master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"master","id":"HEAD"}}}'
);
});
it('pulls and then pushes', function() { it('pulls and then pushes', function() {
expectTreeAsync( expectTreeAsync(
'git clone; git commit; git fakeTeamwork; git pull; git push', 'git clone; git commit; git fakeTeamwork; git pull; git push',

View file

@ -577,24 +577,27 @@ var commandConfig = {
if (isColonRefspec(firstArg)) { if (isColonRefspec(firstArg)) {
var refspecParts = firstArg.split(':'); var refspecParts = firstArg.split(':');
source = refspecParts[0]; source = refspecParts[0];
destination = refspecParts[1]; destination = validateAndAssertBranchName(engine, refspecParts[1]);
// TODO -- assert good branch name
} else { } else {
// we are using this org as both destination and source // we are using this arg as destination -- source is one before head
destination = firstArg; destination = firstArg;
source = firstArg; source = engine.getOneBeforeCommit('HEAD').get('id');
} }
destination = validateAndAssertBranchName(engine, destination);
} else { } else {
source = engine.getOneBeforeCommit('HEAD'); // since they have not specified a source or destination, then
// we source from the branch we are on (or HEAD) and push to
// the branch we are on
source = engine.getOneBeforeCommit('HEAD').get('id');
destination = source; destination = source;
assertBranchIsRemoteTracking(source); assertBranchIsRemoteTracking(engine, source);
} }
if (source) { if (source) {
assertIsRef(engine, source); assertIsRef(engine, source);
} }
engine.push({ engine.push({
// NOTE -- very important! destination and source here
// are always, always strings. very important :D
destination: destination, destination: destination,
source: source source: source
}); });

View file

@ -885,19 +885,16 @@ GitEngine.prototype.push = function(options) {
return; return;
} }
var remoteBranch = this.refs[options.source]; var sourceBranch = this.refs[options.source];
if (!this.origin.refs[options.destination]) { if (!this.origin.refs[options.destination]) {
this.makeBranchOnOriginAndTrack( this.makeBranchOnOriginAndTrack(
options.destination, options.destination,
'HEAD' 'HEAD'
); );
} }
var branchOnRemote = this.origin.refs[options.source]; var branchOnRemote = this.origin.refs[options.destination];
var sourceLocation = this.getOneBeforeCommit(options.source || 'HEAD'); var sourceLocation = this.getOneBeforeCommit(options.source || 'HEAD');
debugger;
// first check if this is even allowed by checking the sync between // first check if this is even allowed by checking the sync between
this.checkUpstreamOfSource( this.checkUpstreamOfSource(
this, this,
@ -971,7 +968,7 @@ GitEngine.prototype.push = function(options) {
// HAX HAX update master and remote tracking for master // HAX HAX update master and remote tracking for master
chain = chain.then(_.bind(function() { chain = chain.then(_.bind(function() {
var localCommit = this.getCommitFromRef(sourceLocation); var localCommit = this.getCommitFromRef(sourceLocation);
this.setTargetLocation(remoteBranch, localCommit); this.setTargetLocation(this.refs[ORIGIN_PREFIX + options.destination], localCommit);
return this.animationFactory.playRefreshAnimation(this.gitVisuals); return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this)); }, this));
@ -2541,6 +2538,9 @@ var Branch = Ref.extend({
}, },
getIsRemote: function() { getIsRemote: function() {
if (typeof this.get('id') !== 'string') {
debugger;
}
return this.get('id').slice(0, 2) === ORIGIN_PREFIX; return this.get('id').slice(0, 2) === ORIGIN_PREFIX;
} }
}); });