Git hooks (prepush/precommit)
See original GitHub issueThis issue is a continuation of #379 discussion about git hooks.
Related issues : #301, #313, #314
I think adding a prepush hook is very good idea, I personally run prepublishOnly
before every of my push.
But for precommit I disagree, it’s unpleasant to wait for it, and lint-staged cannot be used because okonet/lint-staged#62
Issue Analytics
- State:
- Created 6 years ago
- Comments:24 (10 by maintainers)
Top Results From Across the Web
Git Hooks - Git SCM
The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to...
Read more >pre-commit
A framework for managing and maintaining multi-language pre-commit hooks. ... Git hook scripts are useful for identifying simple issues before submission to ...
Read more >Git Hooks | Learn how to use pre-commit hooks, post-commit ...
An introductory guide and resource for Git hooks. Learn how to use pre-commit hooks, post-commit hooks, post-receive hooks, and more.
Read more >python - With pre-commit, how to use some hooks before ...
From that I'm expecting the first couple of hooks to run before a commit (which they do), but I'm expecting black to run...
Read more >Git Hooks | Atlassian Git Tutorial
The pre-receive hook is executed every time somebody uses git push to push commits to the repository. It should always reside in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It looks like it is in general not trivial to fix files in
pre-commit
and do the right thing with partly staged files,pretty-quick
apparently can’t do that too: https://github.com/azz/pretty-quick/issues/6.Maybe the easiest thing to do would be to just validate all the files, don’t try to autofix in
pre-commit
.Also, if there are files which
prettier would reformat,
prettier -l` prints file names and exits with status code 1.Update:
lint-staged
works by passing filenames to eslint (at least their Readme says so), which means it checks version of the file in working directory instead of index. Can be solved by using a simple bash script instead.But…
@guillaumearm I have to agree with you here. To a point that I’m myself wondering if any hooks near commiting are worth it.
Especially
pre-commit
, when now that prettier is run from within eslint, which makes my VSCode fix everything on save (it’s awesome), and entire project will be linted anyway onpre-push
…I’ll probably open a PR adding
pre-push
andcommit-msg
hooks. I think I’ll add each hook in separate commit, so that it’d be easier to merge it only partially. Might as well throw inpre-commit
.