Skip to content

Run all pre commit scripts in commit-msg? #308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
philnash opened this issue Jul 12, 2021 · 3 comments · Fixed by #322
Closed

Run all pre commit scripts in commit-msg? #308

philnash opened this issue Jul 12, 2021 · 3 comments · Fixed by #322

Comments

@philnash
Copy link
Contributor

When git's commit hooks run, they go in the order pre-commit, prepare-commit-msg, commit-msg. This project runs linting and testing during pre-commit and commitlint during commit-msg. If you make a mistake in the commit message, like using too many characters, you have to wait for linting and the entire test suite to run before you find out.

There is no altering the order of commit hooks and you only receive the commit message as an argument during the commit-msg hook.

I propose that all pre commit scripts are run as part of the commit-msg hook with the commitlint script first, followed by linting and testing the project. This will allow for invalid commit messages to exit the commit early while retaining all the previous behaviour.

I don't know of any downsides to using the commit-msg hook for this. It's not how the git docs describe the usage of commit-msg and pre-commit but it would save me (and hopefully other contributors) time when I inevitable make a mistake in the commit message.

Thoughts?

@philnash philnash mentioned this issue Jul 12, 2021
1 task
@dkundel
Copy link
Contributor

dkundel commented Jul 16, 2021

If you are able to still lint on staged files only I'm fine with it.

@philnash
Copy link
Contributor Author

Linting staged commits is a relatively fast process, so that could still live in the pre-commit hook. It's running the entire test suite that takes the time.

Another idea might be to hold off on running the full test suite until pre-push. Meaning you could make in progress commits that fail the build, but aren't able to push them until you have a green test suite.

@dkundel
Copy link
Contributor

dkundel commented Jul 16, 2021

I think that's a better idea! I often end up using --no-verify when doing in progress commits. This would take that away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants