Open jorisroovers opened 1 year ago
Currently we only have 1 meta rule (denoted by rule ids starting withM
) which is M1:author-valid-email
, the idea has always been to add more meta rules at some point, most obviously M2: author-valid-name
. We can create a separate issue for this, happy to take a PR for it as well :-)
If I understand correctly, @webknjaz I think what you’re proposing here is different though. I believe you’re suggesting has 2 distinct parts:
commit
object so they can be used by rules (including user defined rules).Add a new meta rule that allows for validating those trailers, something like:
[trailer-match-regex]
key=Co-Authored-By
regex=^Dependabot
# Named Rules can be used to have multiple of these trailer-match-regex rules
[trailer-match-regex:SignedOffBy]
key=Signed-off-by
regex=^Dependabot
# Perhaps we need an extra option 'trailer-required' to indicate the behavior when the trailer is not present
[trailer-match-regex:SignedOffByRequired]
trailer-required=true # hard fail when no Signed-off-by trailer is present
trailer-required=false # skip rule if no Signed-off-by trailer is present
key=Signed-off-by
regex=^Dependabot
Sounds about right, except I was specifically thinking about the metadata that can be interpreted as contributors. For example, GitHub and other Git hostings show everybody listed in the built-in Author and Committer fields, along with all the entries of Co-Authored-By
as authors of that commit. So there's basically 3 sources of authorship information. I think it only makes sense to validate all of them in the existing rule, instead of just one field — any of them can be broken, not just one field only.
Note that there may be an unlimited amount of
Co-Authored-By
entries in a single commit.
Interesting use-case, I can definitely see the usefulness of this. I'm not sure whether it would be better to implement this as a new rule though, rather than overloading the existing one with a new meaning/behavior.
In order for this to happen, gitlint would also need capture the Committer information, only the Author information (as it does today).
To summarize for when we'd get around to implement this, there's a bunch of work suggested here:
commit
object: Parse committer info (%cN
and %cE
) in addition to the existing author informationcommit
object: Parse trailersauthor-valid-name
ruleauthors-all-valid-email
, authors-all-valid-name
rules (rule name subject to change)I think it makes sense to split these out into separate issues once we start work on this.
Originally posted by @webknjaz in https://github.com/jorisroovers/gitlint/issues/373#issuecomment-1322153613