fix(scripts): gate --apply on main's first-parent line and reject later-landing tags
Why: a commit of an already-merged feature branch is an ancestor of
origin/main, so the ancestor check let --apply walk that branch's
first-parent history and tag a feature commit (git-v1.3.9 on 025ad4a).
A valid annotated tag on a later run of a recurring version was also
accepted as the start point, hiding the versions between its first
landing and that run.
Implementation Notes:
- --apply now requires the ref on origin/main's first-parent list;
otherwise exit 2 and no tags.
- A tag must peel to the FIRST run of its version; one on a later run
is an ERROR row and never the start point.
- apm.yml pathspecs use :(literal), so a plugin name is never a glob.
- Repeated --plugin values are de-duplicated (bash 3.2-safe).
- The printed push hint says the push runs only on the maintainer's
explicit yes to that exact line.
Impact: tests cover all but the literal pathspec, which has no
observable effect on run grouping today and is defensive.
Refs: #223
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
This commit is contained in:
1 parent
c8853c7a44
commit
03bacd6e5a
2 files changed
+106
-20
No files matched your search
@@ -416,7 +416,7 @@ expect_rc "--apply refuses the local-main fallback" 2
|
||||
sync_origin "$R"
|
||||
run "$R" --ref "$FEAT" --apply
|
||||
expect_rc "--apply --ref <feature-branch commit>" 2
|
||||
if grep -q "not on origin/main" <<< "$OUT"; then pass "message names origin/main"; else fail "no origin/main message"; fi
|
||||
if grep -q "not on origin/main's first-parent history" <<< "$OUT"; then pass "message names origin/main's first-parent history"; else fail "no origin/main message"; fi
|
||||
if [[ -z "$(git -C "$R" tag -l)" ]]; then pass "no tag on a feature-branch commit"; else fail "tag created off main"; fi
|
||||
run "$R" --ref "$FEAT"
|
||||
expect_rc "dry run may still read a feature-branch ref" 1
|
||||
@@ -430,6 +430,54 @@ expect_rc "leading-dash plugin" 2
|
||||
if grep -q "must not start with '-'" <<< "$OUT"; then pass "message names the leading dash"; else fail "no leading-dash message"; fi
|
||||
if [[ -z "$(git -C "$R" tag -l)" ]]; then pass "nothing created"; else fail "tags created"; fi
|
||||
|
||||
echo "Case 12q: --apply refuses a commit of an already-merged feature branch"
|
||||
R="$(new_repo)"
|
||||
write_apm "$R" ya 1.0.0; commit "$R" a
|
||||
(cd "$R" && git checkout -q -b feat)
|
||||
write_apm "$R" ya 1.1.0; commit "$R" b; FEAT="$(head_sha "$R")"
|
||||
(cd "$R" && git checkout -q main && git merge -q --no-ff -m "merge feat" feat)
|
||||
MERGED="$(head_sha "$R")"
|
||||
sync_origin "$R"
|
||||
run "$R" --ref "$FEAT" --apply
|
||||
expect_rc "--apply --ref <merged feature commit>" 2
|
||||
if grep -q "not on origin/main's first-parent history" <<< "$OUT"; then pass "message names the first-parent history"; else fail "no first-parent message"; fi
|
||||
if [[ -z "$(git -C "$R" tag -l)" ]]; then pass "no tag on the merged feature commit"; else fail "tags created: $(git -C "$R" tag -l | tr '\n' ' ')"; fi
|
||||
run "$R" --ref "$MERGED" --apply
|
||||
expect_rc "--apply --ref <the merge commit>" 0
|
||||
if [[ "$(git -C "$R" rev-parse "ya-v1.1.0^{commit}" 2>/dev/null)" == "$MERGED" ]]; then pass "ya-v1.1.0 on the merge commit"; else fail "ya-v1.1.0 misplaced"; fi
|
||||
|
||||
echo "Case 12r: a tag on a later run of a recurring version is an ERROR, not a start point"
|
||||
R="$(new_repo)"
|
||||
write_apm "$R" za 1.0.0; commit "$R" a; Z1="$(head_sha "$R")"
|
||||
write_apm "$R" za 1.1.0; commit "$R" b; Z2="$(head_sha "$R")"
|
||||
write_apm "$R" za 1.0.0; commit "$R" revert; Z3="$(head_sha "$R")"
|
||||
write_apm "$R" za 1.2.0; commit "$R" c
|
||||
(cd "$R" && git tag -a za-v1.0.0 -m x "$Z3")
|
||||
sync_origin "$R"
|
||||
run "$R" --ref main
|
||||
expect_rc "tag on a later landing" 2
|
||||
expect_row "row names the later-landing tag" za 1.0.0 "$Z3" ERROR
|
||||
if grep -q "za-v1.0.0 peels to ${Z3:0:7}, a later landing of 1.0.0; it first landed at ${Z1:0:7}" <<< "$OUT"; then pass "message names the first landing"; else fail "no later-landing message"; fi
|
||||
if ! grep -q "${Z2:0:7}.*OK" <<< "$OUT"; then pass "1.1.0 is not hidden behind the bad tag as OK"; else fail "1.1.0 reported OK"; fi
|
||||
run "$R" --ref main --apply
|
||||
expect_rc "--apply blocked by the later-landing tag" 2
|
||||
if [[ "$(git -C "$R" tag -l)" == "za-v1.0.0" ]]; then pass "nothing created"; else fail "tags created: $(git -C "$R" tag -l | tr '\n' ' ')"; fi
|
||||
(cd "$R" && git tag -d za-v1.0.0 > /dev/null && git tag -a za-v1.0.0 -m x "$Z1")
|
||||
run "$R" --ref main
|
||||
expect_rc "tag moved to the first landing" 1
|
||||
expect_row "first landing OK" za 1.0.0 "$Z1" OK
|
||||
expect_row "1.1.0 wanted again" za 1.1.0 "$Z2" MISSING
|
||||
expect_row "later landing RELEASED" za 1.0.0 "$Z3" RELEASED
|
||||
|
||||
echo "Case 12s: a repeated --plugin is de-duplicated"
|
||||
R="$(new_repo)"
|
||||
write_apm "$R" git 1.0.0; write_apm "$R" gitea 1.0.0; commit "$R" a
|
||||
sync_origin "$R"
|
||||
run "$R" --ref main --plugin git --plugin git --apply
|
||||
expect_rc "--plugin git --plugin git --apply" 0
|
||||
if [[ "$(git -C "$R" tag -l)" == "git-v1.0.0" ]]; then pass "one tag created"; else fail "wrong tags: $(git -C "$R" tag -l | tr '\n' ' ')"; fi
|
||||
if grep -qx "git push origin git-v1.0.0" <<< "$OUT"; then pass "push line names the tag once"; else fail "push line wrong"; echo "$OUT" | sed 's/^/ /'; fi
|
||||
|
||||
echo "Case 12p: expect_row matches a version's dots literally"
|
||||
OUT="zz 1x0x0 abcdef0 OK"
|
||||
if ! grep -Eq "^zz +$(ere_quote 1.0.0) +abcdef0 +OK\$" <<< "$OUT"; then pass "1.0.0 does not match 1x0x0"; else fail "unescaped dots"; fi
|
||||
|
||||
Reference in new issue
Block a user