diff --git a/openstack_releases/gitutils.py b/openstack_releases/gitutils.py index e96229a26e..99532735ee 100644 --- a/openstack_releases/gitutils.py +++ b/openstack_releases/gitutils.py @@ -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( diff --git a/openstack_releases/tests/test_validate.py b/openstack_releases/tests/test_validate.py index d074171ee9..af1e529894 100644 --- a/openstack_releases/tests/test_validate.py +++ b/openstack_releases/tests/test_validate.py @@ -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',