Skip to content

Commit b438129

Browse files
charlesprostclaude
andcommitted
Fix regressions from HotfixBranch.hfrev=0 default
Two regressions introduced when HotfixBranch.version was changed to include .0 suffix by default (hfrev=0 class attribute): 1. create_branch.py: archive-tag check fired for HotfixBranch because version='X.Y.Z.0' matched the GA release tag 'X.Y.Z.0'. Skip this check for hotfix branches since their archive tags use the format 'X.Y.Z.hfrev.archived_hotfix_branch'. Also fix branch_from to use the 3-digit base form '%d.%d.%d.0' instead of version+'.0' which would produce 'X.Y.Z.0.0'. 2. branches.py: has_version_queued_prs() was only prefix-matching for hfrev==-1 (legacy sentinel), missing the case where branch_factory() creates a HotfixBranch with hfrev==0 but update_versions() already advanced the queue to hfrev==1 (post-GA). Extend the fallback prefix match to cover hfrev==0 as well, with an exact-match-first strategy to preserve correct pre-GA behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent fe9a238 commit b438129

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

bert_e/jobs/create_branch.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ def create_branch(job: CreateBranchJob):
6262

6363
# do not allow recreating a previously existing identical branch
6464
# (unless archive tag is manually removed)
65-
if new_branch.version in repo.cmd('git tag').split('\n')[:-1]:
65+
# Hotfix archive tags use format 'X.Y.Z.hfrev.archived_hotfix_branch',
66+
# not just 'X.Y.Z.hfrev', so skip this check for hotfix branches.
67+
if not isinstance(new_branch, HotfixBranch) and \
68+
new_branch.version in repo.cmd('git tag').split('\n')[:-1]:
6669
raise exceptions.JobFailure('Cannot create branch %r because there is '
6770
'already an archive tag %r in the '
6871
'repository.' %
@@ -81,8 +84,10 @@ def create_branch(job: CreateBranchJob):
8184
# ...or determine the branching point automatically
8285
else:
8386
if isinstance(new_branch, HotfixBranch):
84-
# start from tag X.Y.Z.0
85-
job.settings.branch_from = new_branch.version + '.0'
87+
# start from tag X.Y.Z.0 (use 3-digit base to avoid double .0)
88+
base_ver = '%d.%d.%d' % (new_branch.major,
89+
new_branch.minor, new_branch.micro)
90+
job.settings.branch_from = base_ver + '.0'
8691
else:
8792
job.settings.branch_from = dev_branches[0]
8893
for dev_branch in dev_branches:

bert_e/workflow/gitwaterflow/branches.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,12 +829,19 @@ def queued_prs(self):
829829
return pr_hf_ids + pr_non_hf_ids
830830

831831
def has_version_queued_prs(self, version):
832-
# delete_branch() may call this property with a four numbers version
833-
# finished by -1, so we can not rely on this last number to match.
834-
if len(version) == 4 and version[3] == -1:
832+
# delete_branch() may call this with a version whose hfrev has not
833+
# been resolved by update_versions (hfrev == -1 legacy, or hfrev == 0
834+
# when branch_factory is called without a cascade). In that case we
835+
# must not rely on the last number to match.
836+
if len(version) == 4 and version[3] in (-1, 0):
837+
# Try exact match first (covers true pre-GA queues where hfrev=0)
838+
exact = self._queues.get(version, {}).get(QueueIntegrationBranch)
839+
if exact is not None:
840+
return True
841+
# Fallback: prefix match (covers post-GA where update_versions
842+
# advanced hfrev but branch_factory still returned hfrev=0)
835843
for queue_version in self._queues.keys():
836844
if len(queue_version) == 4 and \
837-
len(version) == 4 and \
838845
queue_version[:3] == version[:3]:
839846
queued_pr = self._queues.get(queue_version)
840847
if queued_pr is not None and \

0 commit comments

Comments
 (0)