[refs #719] fixed errors with tags & history rewrite

This commit is contained in:
Alexander Machehin 2013-01-28 22:10:26 +06:00
parent 7edcacee00
commit 902438b7b5
1 changed files with 10 additions and 8 deletions

View File

@ -176,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