Skip to content

Check a tag against the main branch once instead of three times - #254

Open
pytooling-claude[bot] wants to merge 1 commit into
devfrom
claude/preparejob-tag-check
Open

Check a tag against the main branch once instead of three times#254
pytooling-claude[bot] wants to merge 1 commit into
devfrom
claude/preparejob-tag-check

Conversation

@pytooling-claude

Copy link
Copy Markdown

Changes

  • A tag is checked against the main branch once instead of three times. For a tag ref,
    PrepareJob.yml ran the identical

    git branch --remotes --contains $(git rev-parse --verify "tags/${tag}~0") | grep "origin/${{ inputs.main_branch }}"

    in three places:

    where guard
    before the tag kind was known none
    after the pattern check is_nightly_tag == 'true'
    after the pattern check 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_kind variable. The classification is exhaustive — a tag matching neither pattern exits before it — so the
    single call covers exactly what the two guarded ones covered.

  • ⚠️ A tag that is neither well-formed nor on the main branch now reports the pattern failure. The unguarded
    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

  • The duplication was introduced by e4b5ea3 ("Check if commit is on default branch."), which added the branch
    classification and appears to have duplicated the tag check along the way. r7 and dev are byte-identical for
    this file, so both carry it.
  • Found while diffing GHDL's integrated copy of this logic against the template. Worth settling before that copy
    is re-synced, because this is one of the few places where the template is stricter than the copy.

@pytooling-claude
pytooling-claude Bot requested a review from Paebbels as a code owner September 7, 2026 20:10
@pytooling-claude pytooling-claude Bot added Documentation Improvements or additions to documentation Enhancement New feature or request JobTmpl: PrepareJob labels Sep 7, 2026
@codacy-production

codacy-production Bot commented Sep 7, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage ∅ diff coverage · +0.00% coverage variation

Metric Results
Coverage variation +0.00% coverage variation
Diff coverage diff coverage

View coverage diff in Codacy

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

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.22%. Comparing base (8e631fc) to head (79ef39a).
✅ All tests successful. No failed tests found.

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           
Flag Coverage Δ
unittests 82.22% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Paebbels
Paebbels force-pushed the claude/preparejob-tag-check branch from 07e4911 to 74e1ad0 Compare September 7, 2026 20:17
@pytooling-claude pytooling-claude Bot mentioned this pull request Sep 7, 2026
@Paebbels
Paebbels force-pushed the claude/preparejob-tag-check branch 2 times, most recently from 3e1878a to a328b07 Compare September 8, 2026 06:22
`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>
@Paebbels
Paebbels force-pushed the claude/preparejob-tag-check branch from a328b07 to 79ef39a Compare September 8, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Enhancement New feature or request JobTmpl: PrepareJob

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant