diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-04-21 13:23:44 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-04-21 13:23:44 +0300 |
commit | ae565d24ee6c0d1f26bc47b3419ca2b58474d7a3 (patch) | |
tree | b9da100fca562e00fecead1975097e25301f5725 | |
parent | 7058258a2afbc3335da7568ea2e2f5337bbc00b4 (diff) | |
download | gitlab-ce-ae565d24ee6c0d1f26bc47b3419ca2b58474d7a3.tar.gz |
Increased automerge timeout. Works for 300 commits MR on repo with 200MB size
-rw-r--r-- | lib/gitlab_merge.rb | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/gitlab_merge.rb b/lib/gitlab_merge.rb index 66a0e7ec635..8e276e0d8a4 100644 --- a/lib/gitlab_merge.rb +++ b/lib/gitlab_merge.rb @@ -28,21 +28,25 @@ class GitlabMerge end def pull - 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) - unless File.exist?(self.merge_path) - raise "Gitlab user do not have access to repo. You should run: rake gitlab_enable_automerge" + Grit::Git.with_timeout(30.seconds) do + 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) + unless File.exist?(self.merge_path) + raise "Gitlab user do not have access to repo. You should run: rake gitlab_enable_automerge" + end + 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 - 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 + + rescue Grit::Git::GitTimeout + return false end end |