kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwens...@apache.org
Subject kafka git commit: KAFKA-2328; merge-kafka-pr.py script should not leave user in a detached branch
Date Mon, 20 Jul 2015 23:41:16 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 1d2bd6284 -> 204089046


KAFKA-2328; merge-kafka-pr.py script should not leave user in a detached branch

The right command to get the branch name is `git rev-parse --abbrev-ref HEAD` instead of `git
rev-parse HEAD`. The latter gives the commit hash causing a detached branch when we checkout
to it. Seems like a bug we inherited from the Spark script.

Author: Ismael Juma <ismael@juma.me.uk>

Closes #84 from ijuma/kafka-2328-merge-script-no-detached-branch and squashes the following
commits:

ae201dd [Ismael Juma] KAFKA-2328; merge-kafka-pr.py script should not leave user in a detached
branch


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/20408904
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/20408904
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/20408904

Branch: refs/heads/trunk
Commit: 2040890462a22614ccb836e43837f8739855b84f
Parents: 1d2bd62
Author: Ismael Juma <ismael@juma.me.uk>
Authored: Mon Jul 20 16:40:54 2015 -0700
Committer: Gwen Shapira <cshapi@gmail.com>
Committed: Mon Jul 20 16:40:54 2015 -0700

----------------------------------------------------------------------
 kafka-merge-pr.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/20408904/kafka-merge-pr.py
----------------------------------------------------------------------
diff --git a/kafka-merge-pr.py b/kafka-merge-pr.py
index 4cc82e0..c6ef3df 100644
--- a/kafka-merge-pr.py
+++ b/kafka-merge-pr.py
@@ -95,8 +95,9 @@ def continue_maybe(prompt):
         fail("Okay, exiting")
 
 def clean_up():
-    print "Restoring head pointer to %s" % original_head
-    run_cmd("git checkout %s" % original_head)
+    if original_head != get_current_branch():
+        print "Restoring head pointer to %s" % original_head
+        run_cmd("git checkout %s" % original_head)
 
     branches = run_cmd("git branch").replace(" ", "").split("\n")
 
@@ -104,6 +105,8 @@ def clean_up():
         print "Deleting local branch %s" % branch
         run_cmd("git branch -D %s" % branch)
 
+def get_current_branch():
+    return run_cmd("git rev-parse --abbrev-ref HEAD").replace("\n", "")
 
 # merge the requested PR and return the merge hash
 def merge_pr(pr_num, target_ref, title, body, pr_repo_desc):
@@ -350,7 +353,7 @@ def standardize_jira_ref(text):
 def main():
     global original_head
 
-    original_head = run_cmd("git rev-parse HEAD")[:8]
+    original_head = get_current_branch()
 
     branches = get_json("%s/branches" % GITHUB_API_BASE)
     branch_names = filter(lambda x: x.startswith(RELEASE_BRANCH_PREFIX), [x['name'] for x
in branches])


Mime
View raw message