diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-01 15:59:44 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-10-02 16:11:32 +0200 |
commit | b09e40624b9fc6a7b4a7b38f174bc66d996e3fd5 (patch) | |
tree | 5bbe4e8da4966bbdbc30e6ab7bcfa50caff1c29b | |
parent | df73116f75d4a7545fb4a7684aa76624efede7d0 (diff) | |
download | gitlab-ce-b09e40624b9fc6a7b4a7b38f174bc66d996e3fd5.tar.gz |
Show the commit-sha for pre-release versions
The pre-release tags are set at the beginning of a release, so it
would be impossible to figure out which version was running if we're
running nightlies.
In that case it's better to still link to the SHA. These versions
don't get deployed to .com.
-rw-r--r-- | app/helpers/version_check_helper.rb | 13 | ||||
-rw-r--r-- | app/views/help/index.html.haml | 2 | ||||
-rw-r--r-- | changelogs/unreleased/bvl-show-pre-release-sha.yml | 5 | ||||
-rw-r--r-- | lib/gitlab.rb | 4 | ||||
-rw-r--r-- | spec/support/stub_version.rb | 8 | ||||
-rw-r--r-- | spec/views/help/index.html.haml_spec.rb | 41 |
6 files changed, 59 insertions, 14 deletions
diff --git a/app/helpers/version_check_helper.rb b/app/helpers/version_check_helper.rb index 75637eb0676..ab77b149072 100644 --- a/app/helpers/version_check_helper.rb +++ b/app/helpers/version_check_helper.rb @@ -9,4 +9,17 @@ module VersionCheckHelper image_url = VersionCheck.new.url image_tag image_url, class: 'js-version-status-badge' end + + def link_to_version + if Gitlab.pre_release? + commit_link = link_to(Gitlab.revision, Gitlab::COM_URL + namespace_project_commits_path('gitlab-org', source_code_project, Gitlab.revision)) + [Gitlab::VERSION, content_tag(:small, commit_link)].join(' ').html_safe + else + link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path('gitlab-org', source_code_project, "v#{Gitlab::VERSION}") + end + end + + def source_code_project + 'gitlab-ce' + end end diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index 198c2d35b29..dfa5d820ce9 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -7,7 +7,7 @@ GitLab Community Edition - if user_signed_in? - %span= link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path('gitlab-org', 'gitlab-ce', "v#{Gitlab::VERSION}") + %span= link_to_version = version_status_badge %hr diff --git a/changelogs/unreleased/bvl-show-pre-release-sha.yml b/changelogs/unreleased/bvl-show-pre-release-sha.yml new file mode 100644 index 00000000000..524b3c374f7 --- /dev/null +++ b/changelogs/unreleased/bvl-show-pre-release-sha.yml @@ -0,0 +1,5 @@ +--- +title: Show SHA for pre-release versions on the help page +merge_request: 22026 +author: +type: changed diff --git a/lib/gitlab.rb b/lib/gitlab.rb index ab6b609d099..7790534d5d7 100644 --- a/lib/gitlab.rb +++ b/lib/gitlab.rb @@ -47,4 +47,8 @@ module Gitlab def self.dev_env_or_com? Rails.env.development? || org? || com? end + + def self.pre_release? + VERSION.include?('pre') + end end diff --git a/spec/support/stub_version.rb b/spec/support/stub_version.rb new file mode 100644 index 00000000000..594ab64e7c6 --- /dev/null +++ b/spec/support/stub_version.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module StubVersion + def stub_version(version, revision) + stub_const('Gitlab::VERSION', version) + allow(Gitlab).to receive(:revision).and_return(revision) + end +end diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb index c8c9c4e773d..34e93d929a7 100644 --- a/spec/views/help/index.html.haml_spec.rb +++ b/spec/views/help/index.html.haml_spec.rb @@ -1,11 +1,18 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'help/index' do + include StubVersion + describe 'version information' do + before do + stub_helpers + end + it 'is hidden from guests' do stub_user(nil) stub_version('8.0.2', 'abcdefg') - stub_helpers render @@ -13,15 +20,28 @@ describe 'help/index' do expect(rendered).not_to match 'abcdefg' end - it 'is shown to users' do - stub_user - stub_version('8.0.2', 'abcdefg') - stub_helpers + context 'when logged in' do + before do + stub_user + end - render + it 'shows a link to the tag to users' do + stub_version('8.0.2', 'abcdefg') + + render + + expect(rendered).to match '8.0.2' + expect(rendered).to have_link('8.0.2', href: %r{https://gitlab.com/gitlab-org/gitlab-(ce|ee)/tags/v8.0.2}) + end + + it 'shows a link to the commit for pre-releases' do + stub_version('8.0.2-pre', 'abcdefg') - expect(rendered).to match '8.0.2' - expect(rendered).to have_link('8.0.2', href: 'https://gitlab.com/gitlab-org/gitlab-ce/tags/v8.0.2') + render + + expect(rendered).to match '8.0.2' + expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/gitlab-(ce|ee)/commits/abcdefg}) + end end end @@ -37,11 +57,6 @@ describe 'help/index' do allow(view).to receive(:user_signed_in?).and_return(user) end - def stub_version(version, revision) - stub_const('Gitlab::VERSION', version) - allow(Gitlab).to receive(:revision).and_return(revision) - end - def stub_helpers allow(view).to receive(:markdown).and_return('') allow(view).to receive(:version_status_badge).and_return('') |