From d3c0fc40a3151322216ae0a8e514ed54bf3c9366 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Mon, 14 Oct 2013 18:20:45 -0700 Subject: [PATCH] more remote tests --- spec/remote.spec.js | 21 +++++++++++++++++++++ src/js/git/commands.js | 1 - src/js/git/index.js | 11 +++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/spec/remote.spec.js b/spec/remote.spec.js index 8357b632..962b999d 100644 --- a/spec/remote.spec.js +++ b/spec/remote.spec.js @@ -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() { expectTreeAsync( 'git branch foo; git clone; git push :master', diff --git a/src/js/git/commands.js b/src/js/git/commands.js index d0c9ec70..ba95abe7 100644 --- a/src/js/git/commands.js +++ b/src/js/git/commands.js @@ -167,7 +167,6 @@ var commandConfig = { // B) specify no args, in which case it figures out // the branch to fetch from the remote tracking // and merges those in. - // so lets switch on A/B here var commandOptions = command.getOptionsMap(); diff --git a/src/js/git/index.js b/src/js/git/index.js index ea4c4b88..fbaad895 100644 --- a/src/js/git/index.js +++ b/src/js/git/index.js @@ -876,6 +876,8 @@ GitEngine.prototype.descendSortDepth = function(objects) { GitEngine.prototype.push = function(options) { options = options || {}; + var didMakeBranch; + if (options.source === "") { // delete case this.pushDeleteRemoteBranch( @@ -887,6 +889,7 @@ GitEngine.prototype.push = function(options) { var sourceBranch = this.refs[options.source]; if (!this.origin.refs[options.destination]) { + didMakeBranch = true; this.makeBranchOnOriginAndTrack( options.destination, 'HEAD' @@ -940,6 +943,14 @@ GitEngine.prototype.push = function(options) { var deferred = Q.defer(); 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) { chain = chain.then(_.bind(function() { return this.animationFactory.playHighlightPromiseAnimation(