Fix gitutils to use release-id

With the new release identification / naming schema [1] (like:
2023.1 Antelope) new stable branch naming was introduced (like:
stable/2023.1). This was not handled in check_branch_sha method
in validate.py, as the method still searches stable/$series.

This patch fixes this by reading the 'release-id' field from
series_status.yaml if present and uses it as stable/<release-id>
for the branch search.

[1] https://governance.openstack.org/tc/reference/release-naming.html

Change-Id: I014b1d6dc561be4db0fc8faa85fb3133e851acfc
This commit is contained in:
Hervé Beraud 2023-03-10 16:14:53 +01:00 committed by Előd Illés
parent c957de2246
commit fb08afc1fa
2 changed files with 21 additions and 2 deletions

View File

@ -19,6 +19,7 @@ import subprocess
from openstack_releases import links
from openstack_releases import processutils
from openstack_releases import series_status
# Disable warnings about insecure connections.
from requests.packages import urllib3
@ -29,6 +30,20 @@ LOG = logging.getLogger(__name__)
GIT_TAG_TEMPLATE = 'https://opendev.org/%s/src/tag/%s'
def get_stable_branch_id(series):
"""Retrieve the stable branch ID of the series.
Returns the release-id if the series has such field, otherwise
returns the series name. This is needed for the new stable branch
naming style: stable/2023.1 (versus the old style: stable/zed).
"""
series_status_data = series_status.SeriesStatus.default()
release_id = series_status_data[series].release_id
if release_id is None:
release_id = series
return str(release_id)
def find_modified_deliverable_files():
"Return a list of files modified by the most recent commit."
results = processutils.check_output(
@ -248,7 +263,7 @@ def check_branch_sha(workdir, repo, series, sha):
if stable/N exists we could not create stable/N-1).
"""
remote_match = 'remotes/origin/stable/%s' % series
remote_match = 'remotes/origin/stable/%s' % get_stable_branch_id(series)
try:
containing_branches = _filter_branches(
processutils.check_output(

View File

@ -875,7 +875,11 @@ class TestValidateReleaseBranchMembership(base.BaseTestCase):
self.assertEqual(0, len(self.ctx.warnings))
self.assertEqual(0, len(self.ctx.errors))
def test_not_descendent(self):
@mock.patch('openstack_releases.gitutils.get_stable_branch_id')
def test_not_descendent(self, get_stable_branch_id):
get_stable_branch_id.configure_mock(
return_value='meiji',
)
deliv = deliverable.Deliverable(
team='team',
series='meiji',