From 38ca702b73297e1d86cf336e9f493dd53d050eec Mon Sep 17 00:00:00 2001 From: Franklin Hu Date: Thu, 19 Jul 2012 11:14:04 -0700 Subject: [PATCH 1/3] Fix merging from a fork --- bin/git-pull-request.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/git-pull-request.rb b/bin/git-pull-request.rb index 10502a5e99f..954305cddaa 100755 --- a/bin/git-pull-request.rb +++ b/bin/git-pull-request.rb @@ -190,8 +190,14 @@ def merge(number) puts " into " + color(base['ref'] + ": " + base['sha'], :green) with_temporary_branch(base) do |tmp| - puts "Merging head to temporary branch" - Git.run("merge --squash #{head['sha']}") + if head['repo']['fork']: + remote = head['repo']['git_url'] + ref = head['ref'] + Git.run("pull --squash #{remote} #{ref}") + else: + puts "Merging head to temporary branch" + Git.run("merge --squash #{head['sha']}") + end commit_msg = merge_commit_msg(pull_request, issue) From 50e7f80dc7820e625803c2deafff7ced5f42b763 Mon Sep 17 00:00:00 2001 From: Franklin Hu Date: Thu, 19 Jul 2012 11:14:32 -0700 Subject: [PATCH 2/3] fix syntax --- bin/git-pull-request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-pull-request.rb b/bin/git-pull-request.rb index 954305cddaa..70a254eb4b1 100755 --- a/bin/git-pull-request.rb +++ b/bin/git-pull-request.rb @@ -194,7 +194,7 @@ def merge(number) remote = head['repo']['git_url'] ref = head['ref'] Git.run("pull --squash #{remote} #{ref}") - else: + else puts "Merging head to temporary branch" Git.run("merge --squash #{head['sha']}") end From d76bcef6713f125980eba2981a0c8519904b4e12 Mon Sep 17 00:00:00 2001 From: Franklin Hu Date: Thu, 19 Jul 2012 11:16:41 -0700 Subject: [PATCH 3/3] don't delete local/remote branches if it's a fork --- bin/git-pull-request.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/git-pull-request.rb b/bin/git-pull-request.rb index 70a254eb4b1..9cadd0e9b9b 100755 --- a/bin/git-pull-request.rb +++ b/bin/git-pull-request.rb @@ -190,7 +190,9 @@ def merge(number) puts " into " + color(base['ref'] + ": " + base['sha'], :green) with_temporary_branch(base) do |tmp| - if head['repo']['fork']: + is_fork = head['repo']['fork'] + + if is_fork: remote = head['repo']['git_url'] ref = head['ref'] Git.run("pull --squash #{remote} #{ref}") @@ -211,9 +213,11 @@ def merge(number) puts "Pushing to origin" Git.run("push origin master") - puts "Deleting local and remote branches" - Git.run("push origin :#{head['ref']}") - Git.run("branch -D #{head['ref']}") + if !is_fork: + puts "Deleting local and remote branches" + Git.run("push origin :#{head['ref']}") + Git.run("branch -D #{head['ref']}") + end end end