cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject git commit: Coho - only call git rebase when there is an update.
Date Fri, 24 May 2013 19:30:04 GMT
Updated Branches:
  refs/heads/master ea2090ae1 -> 9d6e1f504


Coho - only call git rebase when there is an update.


Project: http://git-wip-us.apache.org/repos/asf/cordova-coho/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-coho/commit/9d6e1f50
Tree: http://git-wip-us.apache.org/repos/asf/cordova-coho/tree/9d6e1f50
Diff: http://git-wip-us.apache.org/repos/asf/cordova-coho/diff/9d6e1f50

Branch: refs/heads/master
Commit: 9d6e1f50405f411f762ae6f7d21a8613fbb732d3
Parents: ea2090a
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Fri May 24 15:29:40 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Fri May 24 15:29:40 2013 -0400

----------------------------------------------------------------------
 coho |   35 ++++++++++++++++++++++-------------
 1 files changed, 22 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-coho/blob/9d6e1f50/coho
----------------------------------------------------------------------
diff --git a/coho b/coho
index dbb9809..5a84c1c 100755
--- a/coho
+++ b/coho
@@ -559,21 +559,30 @@ function updateRepos(repos, branches, noFetch) {
 
     if (branches && branches.length) {
         forEachRepo(repos, function(repo) {
-            console.log('Updating ' + repo.repoName);
-            var curBranch = retrieveCurrentBranchName();
-            stashAndPop(repo, function() {
-                branches.forEach(function(branchName) {
-                    if (!remoteBranchExists(repo, branchName)) {
-                        console.warning('Skipping branch. Remote branch "' + branchName +
'" does not exist.');
-                    } else {
-                        if (curBranch != branchName) {
-                            execHelper('git checkout ' + branchName);
-                            curBranch = branchName;
+            var staleBranches = branches.filter(function(branchName) {
+                var curHash = execHelper('git rev-parse ' + branchName, true, true);
+                var newHash = execHelper('git rev-parse ' + repo.remoteName + '/' + branchName,
true, true);
+                return curHash !== newHash;
+            });
+            if (!staleBranches.length) {
+                console.log('Repo already up-to-date: ' + repo.repoName);
+            } else {
+                console.log('Updating ' + repo.repoName);
+                var curBranch = retrieveCurrentBranchName();
+                stashAndPop(repo, function() {
+                    staleBranches.forEach(function(branchName) {
+                        if (!remoteBranchExists(repo, branchName)) {
+                            console.warning('Skipping branch. Remote branch "' + branchName
+ '" does not exist.');
+                        } else {
+                            if (curBranch != branchName) {
+                                execHelper('git checkout ' + branchName);
+                                curBranch = branchName;
+                            }
+                            execHelper('git rebase ' + repo.remoteName + '/' + branchName);
                         }
-                        execHelper('git rebase ' + repo.remoteName + '/' + branchName);
-                    }
+                    });
                 });
-            });
+            }
         });
     }
 }


Mime
View raw message