diff options
author | Valery Sizov <vsv2711@gmail.com> | 2012-04-16 23:37:04 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2012-04-16 23:37:04 +0300 |
commit | 5abbada41e101ff832d036d5d1946d6f89fda771 (patch) | |
tree | 9595dbd0d89cd25ebb6ec0dbc1f13aa4b7d86403 /lib | |
parent | a8e4f3ed888f27629a5e35174cdb19cb6c751c16 (diff) | |
download | gitlab-ce-5abbada41e101ff832d036d5d1946d6f89fda771.tar.gz |
Auto-merge: implemented lock file
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab_merge.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/gitlab_merge.rb b/lib/gitlab_merge.rb index 421750b7638..95942d5ca50 100644 --- a/lib/gitlab_merge.rb +++ b/lib/gitlab_merge.rb @@ -28,14 +28,19 @@ class GitlabMerge end def pull - self.project.repo.git.clone({:branch => merge_request.target_branch}, project.url_to_repo, merge_path) - #TODO When user do not have permissions then raise exception - Dir.chdir(merge_path) do - merge_repo = Grit::Repo.new('.') - 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) + File.open(File.join(Rails.root, "tmp", "merge_repo", "#{project.path}.lock"), "w+") do |f| + f.flock(File::LOCK_EX) + + self.project.repo.git.clone({:branch => merge_request.target_branch}, project.url_to_repo, merge_path) + #TODO When user do not have permissions then raise exception + Dir.chdir(merge_path) do + merge_repo = Grit::Repo.new('.') + 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 |