Commit 5abbada4 authored by Valery Sizov's avatar Valery Sizov

Auto-merge: implemented lock file

parent a8e4f3ed
...@@ -28,14 +28,19 @@ class GitlabMerge ...@@ -28,14 +28,19 @@ class GitlabMerge
end end
def pull def pull
self.project.repo.git.clone({:branch => merge_request.target_branch}, project.url_to_repo, merge_path) File.open(File.join(Rails.root, "tmp", "merge_repo", "#{project.path}.lock"), "w+") do |f|
#TODO When user do not have permissions then raise exception f.flock(File::LOCK_EX)
Dir.chdir(merge_path) do
merge_repo = Grit::Repo.new('.') self.project.repo.git.clone({:branch => merge_request.target_branch}, project.url_to_repo, merge_path)
merge_repo.git.sh "git config user.name \"#{user.name}\"" #TODO When user do not have permissions then raise exception
merge_repo.git.sh "git config user.email \"#{user.email}\"" Dir.chdir(merge_path) do
output = merge_repo.git.pull({}, "--no-ff", "origin", merge_request.source_branch) merge_repo = Grit::Repo.new('.')
yield(merge_repo, output) merge_repo.git.sh "git config user.name \"#{user.name}\""
merge_repo.git.sh "git config user.email \"#{user.email}\""
output = merge_repo.git.pull({}, "--no-ff", "origin", merge_request.source_branch)
yield(merge_repo, output)
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment