Skip to content

Commit

Permalink
Fix merge from forks
Browse files Browse the repository at this point in the history
Author: @franklinhu
Fixes #78
URL: #78
  • Loading branch information
Franklin Hu committed Jul 19, 2012
1 parent df7c3c0 commit f417c9a
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions bin/git-pull-request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,16 @@ 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']}")
is_fork = head['repo']['fork']

if is_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)

Expand All @@ -205,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

Expand Down

0 comments on commit f417c9a

Please sign in to comment.