repolinter icon indicating copy to clipboard operation
repolinter copied to clipboard

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

Open achrinza opened this issue 1 year ago • 0 comments

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 https://github.com/todogroup/repolinter/issues/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.

achrinza avatar Nov 13 '24 11:11 achrinza