Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rules/git-regex-tag-names): add new rule #332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

achrinza
Copy link

@achrinza achrinza commented Nov 13, 2024

Motivation

Git tags are typically used for flagging version releases. Hence it may be expected that these tags follow a certain format.

In a single-package repo, this may just be v0.0.0. For monorepos, it may be packageName-v0.0.0.

As new Git tags cannot be introduced through a PR-style workflow (i.e. they are branch-agnostic), there is little feedback when a new tag is created, and hence may lead to a pollution of non-conforming tags.

This rule uses JavaScript's RegExp as the matching engine as Git itself does not expose a --grep flag through git log or any of the generic ref commands.

This is different from #90, which about detecting 0 Git tags / GitHub releases. This rule does not implement either functionality, however the gitAllTagNames could be used as a basis for enforcing minimum no. of Git tags.

This also does not test allowlist and denylist against an annotated git tag's message. It only tests agains the git tag name.

Proposed Changes

This rule enables Git tag naming enforcement with JavaScript regex.

Test Plan

  • Wrote function-level acceptance tests
  • Manual e2e testing of CLI against dummy Git repos

Future Wishlist

  • ignoreBeforeCommit - Ignore tags pointing to a commit that is parent to a commit. Useful if there's legacy Git tags that cannot be changed
  • ignoreAfterCommit - Ignore tags pointing to a child commit of a commit. Useful when there's a change in Git tag naming conventions but existing commits cannot be changed
  • ignoreTags - An array of literal tag names (no pattern). Useful for one-off mistakes that cannot be remedied

These additional options would support more complex Git repos that have baggage.

--

  • ignoreLightweightTags - Boolean on whether to ignore Git lightweight tags
  • ignoreAnnotatedTags - Boolean on whether to ignore Git annotated tags (git tag -a)

These additional options along with denylist: * would support enforcement of a specific git tag type.

--

  • requireGPGSignedAnnotatedTags - Boolean to enforce GPG-signed annotated tags; Skips lightweight tags
  • requireGPGSignedCommits - Boolean to enforce that Git commits pointed to by the tags are GPG-signed.

These additional options would support enforcement of signed tags/commits. They would execute after the tags are filtered by everything above to allow for granular enforcement.

This rule enables Git tag naming enforcement with JavaScript regex.

Signed-off-by: Rifa Achrinza <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant