diff options
author | Jacob Schatz <jschatz1@gmail.com> | 2017-07-28 13:36:07 -0400 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2017-07-28 13:36:07 -0400 |
commit | 3909c6c06c1f33f441c4d341ff008db9eb7e13c6 (patch) | |
tree | 486a19410decab15ec204f28f0ad0e4a0d981add /app/controllers/projects_controller.rb | |
parent | 71d08bfb1b5ce300c60b577c990f074a54cd3e47 (diff) | |
download | gitlab-ce-3909c6c06c1f33f441c4d341ff008db9eb7e13c6.tar.gz |
Adds new ruby help for dropdowns for branches
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r-- | app/controllers/projects_controller.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c769693255c..8149dee59bd 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -220,13 +220,29 @@ class ProjectsController < Projects::ApplicationController end def refs - branches = BranchesFinder.new(@repository, params).execute.map(&:name) + find_refs = params['find'] + + find_branches = true + find_tags = true + find_commits = true + + if !find_refs.nil? + find_branches = find_refs.include? 'branches' + find_tags = find_refs.include? 'tags' + find_commits = find_refs.include? 'commits' + end - options = { - s_('RefSwitcher|Branches') => branches.take(100) - } + branches = [] + options = {} + + if find_branches + branches = BranchesFinder.new(@repository, params).execute.map(&:name) + options = { + s_('RefSwitcher|Branches') => branches.take(100) + } + end - unless @repository.tag_count.zero? + if @repository.tag_count.nonzero? && find_tags tags = TagsFinder.new(@repository, params).execute.map(&:name) options[s_('RefSwitcher|Tags')] = tags.take(100) @@ -234,7 +250,7 @@ class ProjectsController < Projects::ApplicationController # If reference is commit id - we should add it to branch/tag selectbox ref = Addressable::URI.unescape(params[:ref]) - if ref && options.flatten(2).exclude?(ref) && ref =~ /\A[0-9a-zA-Z]{6,52}\z/ + if ref && options.flatten(2).exclude?(ref) && ref =~ /\A[0-9a-zA-Z]{6,52}\z/ && find_commits options['Commits'] = [ref] end |