Skip to content

Commit c8bda4e

Browse files
committed
feat(release): don't warn when devstack main is ahead only by the VERSION strip
The stable branch's stripped-VERSION commit exists on main by design until dev advances — status now shows it as expected instead of a problem.
1 parent a8bd12c commit c8bda4e

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

scripts/localpibox/stack/release.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ def _repo_action(st: dict, rebase: bool) -> tuple[str, str | None]:
242242
return st["feasibility"], None # ff | merge
243243

244244

245+
def _main_unique_is_version_only(path: Path, dev_b: str, main_b: str) -> bool:
246+
"""True when main's tree differs from dev only in VERSION (the expected
247+
stable-branch strip after a promotion, until dev advances again)."""
248+
out, _err, code = git(path, "diff", "--name-only",
249+
f"origin/{dev_b}", f"origin/{main_b}")
250+
return code == 0 and all(f == "VERSION" for f in out.splitlines() if f)
251+
252+
245253
def _set_commit_author() -> None:
246254
"""Force LocalPibox author identity for git commits made by this process."""
247255
os.environ["GIT_AUTHOR_NAME"] = "localpibox"
@@ -270,8 +278,13 @@ def cmd_release_status(cons: Console) -> int:
270278
elif feas == "aligned":
271279
mark, note = "✅", "aligned"
272280
elif feas == "ahead":
273-
mark, note = "⚠️", f"{main_b} is AHEAD of dev — check its unique commits"
274-
problems += 1
281+
if label == "devstack" and _main_unique_is_version_only(path, dev_b, main_b):
282+
mark, note = "✅", (f"{main_b} ahead only by the stable VERSION "
283+
f"strip (expected after a release, until "
284+
f"dev advances)")
285+
else:
286+
mark, note = "⚠️", f"{main_b} is AHEAD of dev — check its unique commits"
287+
problems += 1
275288
elif feas == "ff":
276289
mark, note = "✅", f"{main_b} {st['main_behind_by']} behind → fast-forward"
277290
elif feas == "merge":

scripts/test_localpibox_release.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,22 @@ def test_release_state_real_conflict(tmpdir):
214214
assert st["feasibility"] == "conflict"
215215

216216

217+
def test_main_unique_version_only(tmpdir):
218+
"""After a promotion, main is ahead of dev only by the VERSION strip —
219+
status must not warn about it."""
220+
clone = _fake_release_repo(tmpdir)
221+
p1, p2 = _patch_release(clone, tmpdir)
222+
with p1, p2:
223+
# main (0.0.8-lpb) vs dev (0.0.9-lpb-dev): main's unique change is VERSION
224+
assert rel._main_unique_is_version_only(clone, "dev", "main") is False
225+
# simulate the post-release state: main == merge(dev) + VERSION strip
226+
_g(clone, "checkout", "-q", "-B", "main", "origin/dev")
227+
(clone / "VERSION").write_text("0.0.9-lpb\n")
228+
_g(clone, "commit", "-qam", "strip")
229+
_g(clone, "push", "-q", "origin", "main")
230+
assert rel._main_unique_is_version_only(clone, "dev", "main") is True
231+
232+
217233
# ─── docs-ready command end-to-end ────────────────────────────────────────
218234

219235
def test_docs_ready_flags_and_pushes(tmpdir):

0 commit comments

Comments
 (0)