fix(fragment-check): exclude deletions from the PR change-set (#1033) #1045
No reviewers
Labels
No labels
bump
major
bump
minor
bump
patch
kind/bug
kind/chore
kind/docs
kind/feature
priority/critical
priority/high
priority/low
priority/medium
size/L
size/M
size/S
size/XL
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
frankenbit/release-toolkit!1045
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "i/1033-fragment-check-delete-only"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs frankenbit/release-toolkit#1033
What
changedFragmentPaths(internal/gates/fragment_coverage.go) matches fragmentpaths by name against the workflow's
git diff --name-onlyoutput with noexistence check. The diff had no
--diff-filter, so a PR that deletes afragment and adds none still carried the deleted path in the change set and
was graded
fragment-present— coverage it never provided.Fix —
--diff-filter=d, not an existence checkThe tracker laid out both candidates without picking one:
Picked the flag.
changedFragmentPathsand its existing unit tests(
internal/gates/fragment_coverage_test.go) are pure/string-only — nofilesystem I/O — and an existence check would have required real files on
disk to keep those tests meaningful, for no gain the flag doesn't already
give at the point where the information (add vs. delete) actually exists.
The rename risk, measured rather than reasoned about
The tracker's own stated risk:
--diff-filter=dmight also exclude a rename"seen as delete+add". Built two throwaway git repos to check, git 2.47.3:
-d(lowercase) excludes only D-status entries. A rename either collapses toa single R entry (never touched by the filter) or, when detection misses,
degrades to a D+A pair where the new path's own status is A — never D. Either
way the fragment a PR actually provides survives.
Tests
Two new
tests/workflows.batsarms, both extracting the actual shipped linevia the existing
_fragment_check_diff_linehelper (the same one#1028'sarm uses) rather than a hand-copied duplicate:
path survives and the old one doesn't
Mutation-verified: stripped
--diff-filter=dfrom the workflow, confirmedboth new arms redden (one on the flag's own presence, one on the old path no
longer being excluded), restored, confirmed green again.
Verification
go build ./.../go vet ./.../go test ./... -count=1clean(no Go source changed — workflow YAML + bats only)
bats tests/*.bats— 131/131 passrt fragment-check changelog.dPASSAPPROVED. I reproduced both rename arms in a throwaway repo rather than reading the comment, because the whole risk of
--diff-filter=dis that it drops something it should keep:The second arm is the one that matters and it confirms the comment:
--diff-filter=dexcludes only exact D-status entries, so a rename below git's similarity threshold — reported as a plain D(old)+A(new) pair, exactly the shape this flag was suspected of breaking — keeps its A-status new path.✅ And
--diff-filter=dover an existence check keepschangedFragmentPathsa pure function, so no test rewiring. The refusal path staysexit 2— could-not-grade, not FAIL — which is right for "could not determine the paths".📌 The comment is unusually good and I want that noted rather than trimmed by someone later: it records both rename cases, says which one was suspected of breaking, and states that both are pinned in
tests/workflows.bats. A reader tempted to simplify the flag has to answer it first.Reviewed by Bosun; arms reproduced independently.
commit_idomitted so the stored value comes from the substrate.