Skip to content
Snippets Groups Projects
Commit 6f3a349836df authored by Stan Hu's avatar Stan Hu
Browse files

Fix stable version tag identification for 16.1.x releases

In https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7681
we found that the `upgrade-minor` QA job was attempting to upgrade
from 16.10 to 16.11 for a merge request targeting `16-1-stable`.  This
occurred because the version matching check only found a stable branch
that started with `16.1`, so `16.11.3` was a valid match.

Fix this by tightening the match to include a period, so that `16.1.`
will match `16.1.7`.

Changelog: fixed
parent 479d0329e7f8
1 merge request!143Merge upstream Omnibus GitLab up to the 17.1 branching point
......@@ -57,7 +57,7 @@
branch_for_version = Build::Info::CI.mr_target_branch_name || branch_name
version = branch_for_version.delete_suffix('-stable').tr('-', '.') if Build::Check.on_stable_branch? || Build::Check.mr_targetting_stable_branch?
output = tags.find { |t| t.start_with?(version) } if version
output = tags.find { |t| t.start_with?("#{version}.") } if version
# If no tags corresponding to the stable branch version was found, we
# fall back to the latest available tag
......@@ -78,7 +78,7 @@
version = branch_for_version.delete_suffix('-stable').tr('-', '.') if Build::Check.on_stable_branch? || Build::Check.mr_targetting_stable_branch?
results = stable_tags.select { |t| t.start_with?(version) } if version
results = stable_tags.select { |t| t.start_with?("#{version}.") } if version
# If no tags corresponding to the stable branch version was found, we
# fall back to the latest available stable tag
......
......@@ -5,8 +5,8 @@
before do
stub_default_package_version
ce_tags = "16.1.1+ce.0\n16.0.0+rc42.ce.0\n15.11.1+ce.0\n15.11.0+ce.0\n15.10.0+ce.0\n15.10.0+rc42.ce.0"
ee_tags = "16.1.1+ee.0\n16.0.0+rc42.ee.0\n15.11.1+ee.0\n15.11.0+ee.0\n15.10.0+ee.0\n15.10.0+rc42.ee.0"
ce_tags = "16.1.1+ce.0\n16.0.0+rc42.ce.0\n15.11.1+ce.0\n15.11.0+ce.0\n15.10.0+ce.0\n15.10.0+rc42.ce.0\n15.1.0+ce.0\n"
ee_tags = "16.1.1+ee.0\n16.0.0+rc42.ee.0\n15.11.1+ee.0\n15.11.0+ee.0\n15.10.0+ee.0\n15.10.0+rc42.ee.0\n15.1.0+ee.0\n"
allow(Gitlab::Util).to receive(:shellout_stdout).with(/git -c versionsort.*ce/).and_return(ce_tags)
allow(Gitlab::Util).to receive(:shellout_stdout).with(/git -c versionsort.*ee/).and_return(ee_tags)
end
......@@ -225,6 +225,17 @@
expect(described_class.latest_tag).to eq('15.10.0+ce.0')
end
end
context 'when they target 15-1-stable' do
before do
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', 'my-feature-branch')
stub_env_var('CI_MERGE_REQUEST_TARGET_BRANCH_NAME', '15-1-stable')
end
it 'returns the latest tag in the 15.1 series' do
expect(described_class.latest_tag).to eq('15.1.0+ce.0')
end
end
end
end
......@@ -363,7 +374,7 @@
end
it 'returns the latest available tag' do
expect(described_class.latest_tag).to eq('16.1.1+ce.0')
expect(described_class.latest_stable_tag).to eq('16.1.1+ce.0')
end
end
......@@ -374,7 +385,18 @@
end
it 'returns the latest tag in the stable version series' do
expect(described_class.latest_tag).to eq('15.10.0+ce.0')
expect(described_class.latest_stable_tag).to eq('15.10.0+ce.0')
end
end
context 'when they target 15-1-stable' do
before do
stub_env_var('CI_MERGE_REQUEST_SOURCE_BRANCH_NAME', 'my-feature-branch')
stub_env_var('CI_MERGE_REQUEST_TARGET_BRANCH_NAME', '15-1-stable')
end
it 'returns the latest tag in the 15.1 series' do
expect(described_class.latest_stable_tag).to eq('15.1.0+ce.0')
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment