diff options
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r-- | app/controllers/projects_controller.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5155ae1b104..e2311971f70 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -252,20 +252,18 @@ class ProjectsController < Projects::ApplicationController end def refs - repository = @project.repository - tags = VersionSorter.rsort(repository.tag_names) - options = { - 'Branches' => repository.branch_names, + 'Branches' => @repository.branch_names, } - if tags.any? - options['Tags'] = tags + unless @repository.tag_count.zero? + options['Tags'] = VersionSorter.rsort(@repository.tag_names) end # If reference is commit id - we should add it to branch/tag selectbox - if @ref && !options.flatten.include?(@ref) && @ref =~ /\A[0-9a-zA-Z]{6,52}\z/ - options['Commits'] = @ref + ref = params[:ref] + if ref && !options.flatten.include?(ref) && ref =~ /\A[0-9a-zA-Z]{6,52}\z/ + options['Commits'] = [ref] end render json: options.to_json |