Merge pull request #864 from warpc/719-tag_pull
[refs #719] fix errors with tags && rewriting history
This commit is contained in:
commit
610e2dc1d0
|
@ -48,6 +48,11 @@ class PullRequest < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def check(do_transaction = true)
|
||||
if do_transaction && !valid?
|
||||
issue.set_close nil
|
||||
issue.save(:validate => false) # FIXME remove this hack
|
||||
return false
|
||||
end
|
||||
res = merge
|
||||
new_status = case res
|
||||
when /Already up-to-date/
|
||||
|
@ -171,16 +176,18 @@ class PullRequest < ActiveRecord::Base
|
|||
end
|
||||
|
||||
Dir.chdir(path) do
|
||||
system 'git', 'checkout', to_ref
|
||||
system 'git', 'pull', 'origin', to_ref
|
||||
if to_project_id == from_project_id
|
||||
system 'git', 'checkout', from_ref
|
||||
system 'git', 'pull', 'origin', from_ref
|
||||
else
|
||||
system 'git', 'fetch', 'head', "+#{from_ref}:#{from_branch}"
|
||||
system 'git', 'tag', '-d', from_ref, to_ref
|
||||
system 'git fetch --tags'
|
||||
tags, head = repo.tags.map(&:name), to_project == from_project ? 'origin' : 'head'
|
||||
unless tags.include? to_ref
|
||||
system 'git', 'checkout', to_ref
|
||||
system 'git', 'reset', '--hard', "origin/#{to_ref}"
|
||||
end
|
||||
unless tags.include? from_ref
|
||||
system 'git', 'branch', '-D', from_branch
|
||||
system 'git', 'fetch', head, "+#{from_ref}:#{from_branch}"
|
||||
end
|
||||
end
|
||||
# TODO catch errors
|
||||
end
|
||||
|
||||
def clean
|
||||
|
|
|
@ -96,6 +96,22 @@ describe PullRequest do
|
|||
@wrong_pull.save
|
||||
@project.pull_requests.joins(:issue).where(:issues => {:title => @wrong_pull.title}).count.should == 0
|
||||
end
|
||||
|
||||
it "should create pull with tag" do
|
||||
system("cd #{@project.path} && git tag 4.7.5.3 $(git rev-parse #{@pull.from_ref})") # TODO REDO through grit
|
||||
@pull = @project.pull_requests.new(:issue_attributes => {:title => 'tag', :body => 'testing'})
|
||||
@pull.issue.user, @pull.issue.project = @user, @pull.to_project
|
||||
@pull.to_ref = 'master'
|
||||
@pull.from_project, @pull.from_ref = @project, '4.7.5.3'
|
||||
@pull.save
|
||||
@project.pull_requests.joins(:issue).where(:issues => {:title => @pull.title}).count.should == 1
|
||||
end
|
||||
|
||||
it "should close pull when deleting from branch" do
|
||||
system("cd #{@project.path} && git branch -D #{@pull.from_branch}")
|
||||
@pull.check
|
||||
@project.pull_requests.joins(:issue).where(:issues => {:title => @pull.title, :status => 'closed'}).count.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
|
|
Loading…
Reference in New Issue