Commit 0aa389b4911221e0ec5730d5342a1c59f37a8015

Authored by Dmitriy Zaporozhets
2 parents ea432f60 a7df646e

Merge branch 'master' of github.com:gitlabhq/gitlabhq

.gitignore
... ... @@ -35,3 +35,4 @@ doc/code/*
35 35 *.log
36 36 public/uploads.*
37 37 public/assets/
  38 +.envrc
... ...
Gemfile
... ... @@ -114,6 +114,7 @@ gem 'settingslogic'
114 114  
115 115 # Misc
116 116 gem "foreman"
  117 +gem 'version_sorter'
117 118  
118 119 # Cache
119 120 gem "redis-rails"
... ...
Gemfile.lock
... ... @@ -537,6 +537,7 @@ GEM
537 537 raindrops (~> 0.7)
538 538 unicorn-worker-killer (0.4.2)
539 539 unicorn (~> 4)
  540 + version_sorter (1.1.0)
540 541 virtus (1.0.1)
541 542 axiom-types (~> 0.0.5)
542 543 coercible (~> 1.0)
... ... @@ -662,4 +663,5 @@ DEPENDENCIES
662 663 underscore-rails (~> 1.4.4)
663 664 unicorn (~> 4.6.3)
664 665 unicorn-worker-killer
  666 + version_sorter
665 667 webmock
... ...
app/helpers/application_helper.rb
... ... @@ -89,16 +89,15 @@ module ApplicationHelper
89 89 "Never"
90 90 end
91 91  
92   - def grouped_options_refs(destination = :tree)
  92 + def grouped_options_refs
93 93 repository = @project.repository
94 94  
95 95 options = [
96 96 ["Branches", repository.branch_names],
97   - ["Tags", repository.tag_names]
  97 + ["Tags", VersionSorter.rsort(repository.tag_names)]
98 98 ]
99 99  
100   - # If reference is commit id -
101   - # we should add it to branch/tag selectbox
  100 + # If reference is commit id - we should add it to branch/tag selectbox
102 101 if(@ref && !options.flatten.include?(@ref) &&
103 102 @ref =~ /^[0-9a-zA-Z]{6,52}$/)
104 103 options << ["Commit", [@ref]]
... ...
lib/tasks/gitlab/check.rake
... ... @@ -489,7 +489,7 @@ namespace :gitlab do
489 489 "sudo -u #{gitlab_shell_ssh_user} ln -sf #{gitlab_shell_hook_file} #{project_hook_file}"
490 490 )
491 491 for_more_information(
492   - "#{gitlab_shell_user_home}/gitlab-shell/support/rewrite-hooks.sh"
  492 + "#{gitlab_shell_path}/support/rewrite-hooks.sh"
493 493 )
494 494 fix_and_rerun
495 495 next
... ... @@ -513,7 +513,7 @@ namespace :gitlab do
513 513 end
514 514  
515 515 def check_gitlab_shell_self_test
516   - gitlab_shell_repo_base = File.expand_path('gitlab-shell', gitlab_shell_user_home)
  516 + gitlab_shell_repo_base = gitlab_shell_path
517 517 check_cmd = File.expand_path('bin/check', gitlab_shell_repo_base)
518 518 puts "Running #{check_cmd}"
519 519 if system(check_cmd, chdir: gitlab_shell_repo_base)
... ... @@ -559,8 +559,8 @@ namespace :gitlab do
559 559 # Helper methods
560 560 ########################
561 561  
562   - def gitlab_shell_user_home
563   - File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}")
  562 + def gitlab_shell_path
  563 + Gitlab.config.gitlab_shell.path
564 564 end
565 565  
566 566 def gitlab_shell_version
... ...
spec/helpers/application_helper_spec.rb
... ... @@ -116,7 +116,45 @@ describe ApplicationHelper do
116 116 allow(self).to receive(:request).and_return(double(:ssl? => false))
117 117 gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + " ")
118 118 end
  119 + end
  120 +
  121 + describe "grouped_options_refs" do
  122 + # Override Rails' grouped_options_for_select helper since HTML is harder to work with
  123 + def grouped_options_for_select(options, *args)
  124 + options
  125 + end
  126 +
  127 + let(:options) { grouped_options_refs }
  128 +
  129 + before do
  130 + # Must be an instance variable
  131 + @project = create(:project)
  132 + end
  133 +
  134 + it "includes a list of branch names" do
  135 + options[0][0].should == 'Branches'
  136 + options[0][1].should include('master', 'stable')
  137 + end
  138 +
  139 + it "includes a list of tag names" do
  140 + options[1][0].should == 'Tags'
  141 + options[1][1].should include('v0.9.4','v1.2.0')
  142 + end
  143 +
  144 + it "includes a specific commit ref if defined" do
  145 + # Must be an instance variable
  146 + @ref = '2ed06dc41dbb5936af845b87d79e05bbf24c73b8'
119 147  
  148 + options[2][0].should == 'Commit'
  149 + options[2][1].should == [@ref]
  150 + end
  151 +
  152 + it "sorts tags in a natural order" do
  153 + # Stub repository.tag_names to make sure we get some valid testing data
  154 + expect(@project.repository).to receive(:tag_names).and_return(["v1.0.9", "v1.0.10", "v2.0", "v3.1.4.2", "v1.0.9a"])
  155 +
  156 + options[1][1].should == ["v3.1.4.2", "v2.0", "v1.0.10", "v1.0.9a", "v1.0.9"]
  157 + end
120 158 end
121 159  
122 160 describe "user_color_scheme_class" do
... ...