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.
From: David Shea dshea@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']])
The changes look good to me. So if we still want it, let's rebase and push it.
Added label: ACK.
There was some issue with this last version but I can't remember what it is anymore. I'll take a look at it next week or so.
Closed.
I'm going to stop pretending I'm about to work on this any time soon. There was some issue with the commit id I was using for the base of the merge/rebase, and if I ever fix that I'll open a new PR.
anaconda-patches@lists.fedorahosted.org