question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add ability to pass arbitrary git log arguments

See original GitHub issue

Issue

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:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
morriswinklercommented, Aug 30, 2022

Gave it a try works very well thanks for that uncomplicated process.

0reactions
escapedcatcommented, Aug 27, 2022

Released, please give it a try

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add ability to pass arbitrary extra arguments to git log #591
Describe the feature that you'd like A number of current feature requests essentially boil down to "expose this existing git log argument".
Read more >
Advanced Git Log | Atlassian Git Tutorial
The -- parameter is used to tell git log that subsequent arguments are file paths and not branch names. If there's no chance...
Read more >
git-log Documentation - Git
This can be used to find the set of changes in a topic branch from the point where it diverged from the remote...
Read more >
How can I write a bash function that puts all arguments into ...
This will solve your problem: function commit() { git commit -m "$*"; }.
Read more >
How to pass all arguments passed to my Bash script to a ...
If you want to pass all but the first arguments, you can first use shift to "consume" the first argument and then pass...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found