feat(rules/git-regex-tag-names): add new rule #332
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 bepackageName-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 throughgit 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
anddenylist
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
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 changedignoreAfterCommit
- 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 changedignoreTags
- An array of literal tag names (no pattern). Useful for one-off mistakes that cannot be remediedThese additional options would support more complex Git repos that have baggage.
--
ignoreLightweightTags
- Boolean on whether to ignore Git lightweight tagsignoreAnnotatedTags
- 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 tagsrequireGPGSignedCommits
- 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.