Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnnabel Dunstone Gray <annabel.dunstone@gmail.com>2017-11-08 00:49:27 +0300
committerAnnabel Dunstone Gray <annabel.dunstone@gmail.com>2017-11-08 00:49:27 +0300
commitd9313795e744c83d1b2c7235b34438a87554562d (patch)
treee78ef594e4b672d9cb39b06bdb6243cf53016626 /app/controllers/projects
parent673b6be1fecedd3a4e7126134f3a764694fcf327 (diff)
parentfb41187b7ff6154675ab07b75c8be1067efa8f69 (diff)
Merge branch '37824-many-branches-lock-server' into 'master'
Project with many branches can lock server running "git branch --contains XXX" Closes #37824 See merge request gitlab-org/gitlab-ce!14812
Diffstat (limited to 'app/controllers/projects')
-rw-r--r--app/controllers/projects/commit_controller.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index a62f05db7db..494d412b532 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -16,6 +16,8 @@ class Projects::CommitController < Projects::ApplicationController
before_action :define_note_vars, only: [:show, :diff_for_path]
before_action :authorize_edit_tree!, only: [:revert, :cherry_pick]
+ BRANCH_SEARCH_LIMIT = 1000
+
def show
apply_diff_view_cookie!
@@ -56,8 +58,14 @@ class Projects::CommitController < Projects::ApplicationController
end
def branches
- @branches = @project.repository.branch_names_contains(commit.id)
- @tags = @project.repository.tag_names_contains(commit.id)
+ # branch_names_contains/tag_names_contains can take a long time when there are thousands of
+ # branches/tags - each `git branch --contains xxx` request can consume a cpu core.
+ # so only do the query when there are a manageable number of branches/tags
+ @branches_limit_exceeded = @project.repository.branch_count > BRANCH_SEARCH_LIMIT
+ @branches = @branches_limit_exceeded ? [] : @project.repository.branch_names_contains(commit.id)
+
+ @tags_limit_exceeded = @project.repository.tag_count > BRANCH_SEARCH_LIMIT
+ @tags = @tags_limit_exceeded ? [] : @project.repository.tag_names_contains(commit.id)
render layout: false
end