more remote tests

This commit is contained in:
Peter Cottle 2013-10-14 18:20:45 -07:00
parent 04ce98fd7f
commit d3c0fc40a3
3 changed files with 32 additions and 1 deletions

View file

@ -149,6 +149,27 @@ describe('Git Remotes', function() {
); );
}); });
it('pushes new branch onto server', function() {
expectTreeAsync(
'git clone; git commit; git push origin foo',
'{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null},"o/foo":{"target":"C2","id":"o/foo","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":"C1","id":"master","remoteTrackingBranchID":null},"foo":{"target":"C2","id":"foo","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('does not push for HEAD', function() {
expectTreeAsync(
'git clone; git commit; git checkout C2; git push',
'{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"C2","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"}},"HEAD":{"target":"master","id":"HEAD"}}}'
);
});
it('does push for HEAD as a source though to a new branch', function() {
expectTreeAsync(
'git clone; git commit; git checkout C2; git push HEAD:foo',
'{"branches":{"master":{"target":"C2","id":"master","remoteTrackingBranchID":"o/master"},"o/master":{"target":"C1","id":"o/master","remoteTrackingBranchID":null},"o/foo":{"target":"C2","id":"o/foo","remoteTrackingBranchID":null}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true},"C1":{"parents":["C0"],"id":"C1"},"C2":{"parents":["C1"],"id":"C2"}},"HEAD":{"target":"C2","id":"HEAD"},"originTree":{"branches":{"master":{"target":"C1","id":"master","remoteTrackingBranchID":null},"foo":{"target":"C2","id":"foo","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('but it cant delete master on remote', function() { it('but it cant delete master on remote', function() {
expectTreeAsync( expectTreeAsync(
'git branch foo; git clone; git push :master', 'git branch foo; git clone; git push :master',

View file

@ -167,7 +167,6 @@ var commandConfig = {
// B) specify no args, in which case it figures out // B) specify no args, in which case it figures out
// the branch to fetch from the remote tracking // the branch to fetch from the remote tracking
// and merges those in. // and merges those in.
// so lets switch on A/B here // so lets switch on A/B here
var commandOptions = command.getOptionsMap(); var commandOptions = command.getOptionsMap();

View file

@ -876,6 +876,8 @@ GitEngine.prototype.descendSortDepth = function(objects) {
GitEngine.prototype.push = function(options) { GitEngine.prototype.push = function(options) {
options = options || {}; options = options || {};
var didMakeBranch;
if (options.source === "") { if (options.source === "") {
// delete case // delete case
this.pushDeleteRemoteBranch( this.pushDeleteRemoteBranch(
@ -887,6 +889,7 @@ GitEngine.prototype.push = function(options) {
var sourceBranch = this.refs[options.source]; var sourceBranch = this.refs[options.source];
if (!this.origin.refs[options.destination]) { if (!this.origin.refs[options.destination]) {
didMakeBranch = true;
this.makeBranchOnOriginAndTrack( this.makeBranchOnOriginAndTrack(
options.destination, options.destination,
'HEAD' 'HEAD'
@ -940,6 +943,14 @@ GitEngine.prototype.push = function(options) {
var deferred = Q.defer(); var deferred = Q.defer();
var chain = deferred.promise; var chain = deferred.promise;
if (didMakeBranch) {
chain = chain.then(_.bind(function() {
// play something for both
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
return this.animationFactory.playRefreshAnimation(this.gitVisuals);
}, this));
}
_.each(commitsToMake, function(commitJSON) { _.each(commitsToMake, function(commitJSON) {
chain = chain.then(_.bind(function() { chain = chain.then(_.bind(function() {
return this.animationFactory.playHighlightPromiseAnimation( return this.animationFactory.playHighlightPromiseAnimation(