Commit b09e4062 authored by Bob Van Landuyt's avatar Bob Van Landuyt

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.
parent df73116f
...@@ -9,4 +9,17 @@ module VersionCheckHelper ...@@ -9,4 +9,17 @@ module VersionCheckHelper
image_url = VersionCheck.new.url image_url = VersionCheck.new.url
image_tag image_url, class: 'js-version-status-badge' image_tag image_url, class: 'js-version-status-badge'
end 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 end
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
GitLab GitLab
Community Edition Community Edition
- if user_signed_in? - 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 = version_status_badge
%hr %hr
......
---
title: Show SHA for pre-release versions on the help page
merge_request: 22026
author:
type: changed
...@@ -47,4 +47,8 @@ module Gitlab ...@@ -47,4 +47,8 @@ module Gitlab
def self.dev_env_or_com? def self.dev_env_or_com?
Rails.env.development? || org? || com? Rails.env.development? || org? || com?
end end
def self.pre_release?
VERSION.include?('pre')
end
end end
# 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
# frozen_string_literal: true
require 'rails_helper' require 'rails_helper'
describe 'help/index' do describe 'help/index' do
include StubVersion
describe 'version information' do describe 'version information' do
before do
stub_helpers
end
it 'is hidden from guests' do it 'is hidden from guests' do
stub_user(nil) stub_user(nil)
stub_version('8.0.2', 'abcdefg') stub_version('8.0.2', 'abcdefg')
stub_helpers
render render
...@@ -13,15 +20,28 @@ describe 'help/index' do ...@@ -13,15 +20,28 @@ describe 'help/index' do
expect(rendered).not_to match 'abcdefg' expect(rendered).not_to match 'abcdefg'
end end
it 'is shown to users' do context 'when logged in' do
stub_user before do
stub_version('8.0.2', 'abcdefg') stub_user
stub_helpers 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' render
expect(rendered).to have_link('8.0.2', href: 'https://gitlab.com/gitlab-org/gitlab-ce/tags/v8.0.2')
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
end end
...@@ -37,11 +57,6 @@ describe 'help/index' do ...@@ -37,11 +57,6 @@ describe 'help/index' do
allow(view).to receive(:user_signed_in?).and_return(user) allow(view).to receive(:user_signed_in?).and_return(user)
end end
def stub_version(version, revision)
stub_const('Gitlab::VERSION', version)
allow(Gitlab).to receive(:revision).and_return(revision)
end
def stub_helpers def stub_helpers
allow(view).to receive(:markdown).and_return('') allow(view).to receive(:markdown).and_return('')
allow(view).to receive(:version_status_badge).and_return('') allow(view).to receive(:version_status_badge).and_return('')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment