[refs #90] fixed merge
This commit is contained in:
parent
85d4489009
commit
bd2bb2b91f
|
@ -14,12 +14,12 @@ class Projects::PullRequestsController < Projects::BaseController
|
|||
@pull.head_project = @project
|
||||
|
||||
@pull.base_ref = @pull.base_project.default_branch
|
||||
@pull.head_ref = "head_#{params[:treeish].presence || @pull.head_project.default_branch}"
|
||||
@pull.head_ref = params[:treeish].presence || @pull.head_project.default_branch
|
||||
@pull.check
|
||||
|
||||
repo = Git::Repository.new(@pull.path)
|
||||
@base_commit = repo.commits(@pull.base_ref).first
|
||||
@head_commit = repo.commits(@pull.head_ref).first
|
||||
@head_commit = repo.commits(@pull.head_branch).first
|
||||
|
||||
@diff = Grit::Repo.new(@pull.path).diff @base_commit, @head_commit
|
||||
end
|
||||
|
|
|
@ -84,10 +84,10 @@ class PullRequest < ActiveRecord::Base
|
|||
system 'git', 'checkout', base_ref
|
||||
|
||||
base_project.branches.each do |branch|
|
||||
system 'git', 'branch', '-D', branch.name unless [base_ref, "head_#{head_ref}"].include? branch.name
|
||||
system 'git', 'branch', '-D', branch.name unless [base_ref, head_branch].include? branch.name
|
||||
end
|
||||
base_project.tags.each do |tag|
|
||||
system 'git', 'tag', '-d', tag.name unless [base_ref, "head_#{head_ref}"].include? tag.name
|
||||
system 'git', 'tag', '-d', tag.name unless [base_ref, head_branch].include? tag.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -101,11 +101,19 @@ class PullRequest < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def head_branch
|
||||
if base_project != head_project
|
||||
"head_#{head_ref}"
|
||||
else
|
||||
head_ref
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def merge
|
||||
clone
|
||||
%x(cd #{path} && git checkout #{base_ref} && git merge --no-ff head_#{head_ref}) #FIXME need sanitize branch name!
|
||||
%x(cd #{path} && git checkout #{base_ref} && git merge --no-ff #{head_branch}) #FIXME need sanitize branch name!
|
||||
end
|
||||
|
||||
def clone
|
||||
|
@ -129,7 +137,7 @@ class PullRequest < ActiveRecord::Base
|
|||
system 'git', 'checkout', head_ref
|
||||
system 'git', 'pull', 'origin', head_ref
|
||||
else
|
||||
system 'git', 'fetch', 'head', "+#{head_ref}:head_#{head_ref}"
|
||||
system 'git', 'fetch', 'head', "+#{head_ref}:#{head_branch}"
|
||||
end
|
||||
end
|
||||
# TODO catch errors
|
||||
|
|
Loading…
Reference in New Issue