Skip to content

Commit d904bee

Browse files
charlesprostclaude
andcommitted
(Risk 2) Keep phantom hotfix hfrev/version fresh in update_versions
Phantom hotfixes (stored in _phantom_hotfixes for non-hotfix PR cascades) were never iterated by update_versions(), leaving their .hfrev and .version frozen at the initial pre-GA values forever. Today only .minor is consumed (_update_major_versions), so there is no live bug, but any future caller reading .hfrev or .version would silently get stale data. Apply the same hfrev advancement logic to phantom hotfixes inside update_versions() so their state stays consistent with the cascade. Add a QuickTest that builds a cascade with a phantom hotfix, processes a GA tag, and asserts hfrev advances to 1. The test fails without the fix because the phantom is never updated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7424b7b commit d904bee

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

bert_e/tests/test_bert_e.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,33 @@ def test_branch_cascade_2digit_with_pre_ga_hotfix(self):
540540
fixver = ['9.5.3', '10.0.1', '10.1.0']
541541
self.finalize_cascade(branches, tags, destination, fixver)
542542

543+
def test_phantom_hotfix_hfrev_updated_by_ga_tag(self):
544+
"""Phantom hotfix hfrev and version must be updated by update_versions.
545+
546+
When hotfix/10.0.0 is stored as a phantom (non-hotfix PR destination),
547+
update_versions() must still advance its hfrev when GA tags arrive.
548+
Without the fix the phantom's hfrev stays at 0 forever, exposing
549+
stale data to any future caller that reads .hfrev or .version.
550+
"""
551+
my_dst = gwfb.branch_factory(FakeGitRepo(), 'development/10')
552+
cascade = gwfb.BranchCascade()
553+
for name in ('development/9.5', 'hotfix/10.0.0', 'development/10'):
554+
cascade.add_branch(gwfb.branch_factory(FakeGitRepo(), name),
555+
my_dst)
556+
557+
self.assertEqual(len(cascade._phantom_hotfixes), 1)
558+
phantom = cascade._phantom_hotfixes[0]
559+
560+
# Pre-GA: no 10.0.0.X tags — hfrev must remain 0
561+
cascade.update_versions('9.5.2')
562+
self.assertEqual(phantom.hfrev, 0)
563+
self.assertEqual(phantom.version, '10.0.0.0')
564+
565+
# GA tag 10.0.0.0 lands — phantom hfrev must advance to 1
566+
cascade.update_versions('10.0.0.0')
567+
self.assertEqual(phantom.hfrev, 1) # fails without the fix
568+
self.assertEqual(phantom.version, '10.0.0.1')
569+
543570
def test_branch_cascade_target_three_digit_dev(self):
544571
"""Test cascade targeting three-digit development branch"""
545572
destination = 'development/4.3.17'

bert_e/workflow/gitwaterflow/branches.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,17 @@ def update_versions(self, tag):
10181018
hf_branch.micro,
10191019
hf_branch.hfrev)
10201020

1021+
# Also update phantom hotfixes (stored outside _cascade for dev PRs).
1022+
# They are only consumed for their .minor today, but keeping .hfrev
1023+
# and .version current prevents stale data surprises in future callers.
1024+
for phantom in self._phantom_hotfixes:
1025+
if (phantom.major == major and phantom.minor == minor and
1026+
phantom.micro == micro):
1027+
phantom.hfrev = max(hfrev + 1, phantom.hfrev)
1028+
phantom.version = '%d.%d.%d.%d' % (
1029+
phantom.major, phantom.minor,
1030+
phantom.micro, phantom.hfrev)
1031+
10211032
if micro_branch is not None and \
10221033
([micro_branch.major, micro_branch.minor,
10231034
micro_branch.micro] == [major, minor, micro]):

0 commit comments

Comments
 (0)