Check a tag against the main branch once instead of three times - #254
Check a tag against the main branch once instead of three times#254pytooling-claude[bot] wants to merge 1 commit into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | ✅ +0.00% coverage variation |
| Diff coverage | ✅ ∅ diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (8e631fc) 45 41 91.11% Head commit (79ef39a) 45 (+0) 41 (+0) 91.11% (+0.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#254) 0 0 ∅ (not applicable) Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #254 +/- ##
=======================================
Coverage 82.22% 82.22%
=======================================
Files 1 1
Lines 45 45
Branches 9 9
=======================================
Hits 37 37
Misses 4 4
Partials 4 4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
07e4911 to
74e1ad0
Compare
3e1878a to
a328b07
Compare
`PrepareJob.yml` ran the identical `git branch --remotes --contains ... | grep "origin/<main_branch>"` three times for a tag ref: once unguarded before the tag kind was known, then again under `is_nightly_tag`, then again under `is_release_tag`. The two guarded copies differed from each other only in the word "nightly" or "release" in their message. The check now runs once, after the regular expression has classified the tag, and names the kind through a new `tag_kind` variable. The unguarded copy also decided which error a non-conforming tag produced. A tag that matches neither pattern *and* is not on the main branch used to be rejected with "Tag isn't on branch"; it is now rejected with "doesn't conform to regexp", which is the more useful of the two. Every other case is unchanged. Verified against a scratch repository with a tag on `main`, a nightly tag on `main`, a release tag on a side branch, a non-conforming tag on `main`, and a non-conforming tag on a side branch. The exit code matches the previous implementation in all five cases; only the last one's message differs. Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
a328b07 to
79ef39a
Compare
Changes
A tag is checked against the main branch once instead of three times. For a tag ref,
PrepareJob.ymlran the identicalin three places:
is_nightly_tag == 'true'is_release_tag == 'true'The two guarded copies differed from each other only in the word nightly or release in their message. The
check now runs once, after the regular expression has classified the tag, and names the kind through a new
tag_kindvariable. The classification is exhaustive — a tag matching neither pattern exits before it — so thesingle call covers exactly what the two guarded ones covered.
copy decided which of the two errors such a tag produced: it ran first, so "Tag isn't on branch" won. Now the
pattern check runs first and "doesn't conform to regexp" wins, which is the more useful message — the tag is
not a release candidate at all, so where it sits is beside the point. Exit code and annotation count are
unchanged; only the text differs, and only for that one combination.
Removing the unguarded copy also removes any possibility of a future tag kind that is deliberately not on the
main branch, which the unconditional check would have blocked outright.
Related Issues and Pull-Requests
e4b5ea3("Check if commit is on default branch."), which added the branchclassification and appears to have duplicated the tag check along the way.
r7anddevare byte-identical forthis file, so both carry it.
is re-synced, because this is one of the few places where the template is stricter than the copy.