add ability to pass arbitrary git log arguments
See original GitHub issueIssue
Currently it is impossible to add any additional parameters to git log
when using commitlint
cli parameter --from
.
I am sure you are aware of the need to be able to modify the git log behaviour, there are many corner cases that can be tackled by adding additional arguments to git
.
My specific case is based on merging unrelated history, in which case git log traverses through all the merged in dangling branches, which ends up in a lot of commits being validated.
To fix it I needed to add --first-parent
to git log so it doesn’t traverse into the merged history.
My current fix is to pass the commit messages one by one to commitlint
via a for loop that exits on error.
for sha in $(git log --first-parent --format='%H' master..HEAD);do git log -1 --format='%B' $sha | npx commitlint || ! break; done
An alternative could be to allow a list of commits via the stdin, I guess you would have to add a delimiter option, similar how the
--from
option splits messages into an array. As far as I can see you log with the option:
--format='%B%n------------------------ >8 ------------------------'
and split the messages by ------------------------ >8 ------------------------
since commit messages can’t be split by new lines.
Affected packages
- cli
- core
Executable | Version |
---|---|
commitlint --version |
@commitlint/cli@17.0.3 |
git --version |
git version 2.36.1 |
node --version |
v16.16.0 |
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Gave it a try works very well thanks for that uncomplicated process.
Released, please give it a try