[master 1/2] Fix issues with fetching pull requests.

dashea installerbot-noreply at redhat.com
Tue Mar 24 17:53:11 UTC 2015


From: David Shea <dshea at redhat.com>

The "base" SHA is not actually where the pull request branched from,
though that would be pretty handy. Instead of trying to find a point to
branch from, just fetch the PR branch into a new local branch and rebase
that onto the destination branch.
---
 scripts/merge-pr | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/scripts/merge-pr b/scripts/merge-pr
index a307334..fd98e79 100755
--- a/scripts/merge-pr
+++ b/scripts/merge-pr
@@ -180,22 +180,12 @@ def main():
 
     # Start messing with the git repo
 
-    # Try checking out the base of the PR. If it isn't available, do a fetch of
-    # the base repo and try again.
-    try:
-        subprocess.check_call(['git', 'checkout', '-q', pr['base']['sha']], stderr=DEVNULL)
-    except subprocess.CalledProcessError:
-        try:
-            subprocess.check_call(['git', 'fetch', '-q', pr['base']['repo']['clone_url'], pr['base']['sha']])
-            subprocess.check_call(['git', 'checkout', '-q', pr['base']['sha']])
-        except subprocess.CalledProcessError:
-            sys.exit(1)
-
     try:
+        # Fetch the PR branch into a new local branch.
         branch_name = 'merge-pr-%s-%s' % (pr['head']['user']['login'], pr['head']['ref'])
-        # Create a branch for the PR and pull the data into it
-        subprocess.check_call(['git', 'checkout', '-q', '-b', branch_name])
-        subprocess.check_call(['git', 'pull', '-q', '--ff-only', pr['head']['repo']['clone_url'], pr['head']['sha']])
+        subprocess.check_call(['git', 'fetch', '-q', '--no-tags', pr['head']['repo']['clone_url'],
+            '%s:%s' % (pr['head']['ref'], branch_name)])
+        subprocess.check_call(['git', 'checkout', '-q', branch_name])
 
         # Rebase the PR to the current state of the target branch
         subprocess.check_call(['git', 'rebase', '-q', pr['base']['ref']])


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/13d4cefa3fdfc9e27f775e18090894fa42856db1


More information about the anaconda-patches mailing list