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.

Git hooks (prepush/precommit)

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
wojpawlikcommented, Feb 19, 2018

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.

1reaction
wojpawlikcommented, Feb 22, 2018

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…

Anyway, `npm run + husky + lint-staged + commitlint1 is not about waiting 1 second but 3-4 seconds, I do not like to wait so much. 1 second would be fine. (https://github.com/char0n/ramda-adjunct/issues/386#issuecomment-366728977)

@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 on pre-push

I’ll probably open a PR adding pre-push and commit-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 in pre-commit.

Read more comments on GitHub >

github_iconTop 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 >

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