Thefuck: Support --no-verify in pre-commit hooks - feature request

Created on 15 May 2020  Β·  7Comments  Β·  Source: nvbn/thefuck

thefuck --version:

The Fuck 3.30 using Python 3.8.2 and ZSH 5.3

Your system (Debian 7, ArchLinux, Windows, etc.):

MacOS

How to reproduce the bug:

Have a repo with a pre-commit hook, make sure this hook fails, run `git commit`
The output of the git cmd would be something like this:

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2020-05-15T12_44_24_633Z-debug.log
husky > pre-commit hook failed (add --no-verify to bypass)

In the above example I used https://github.com/typicode/husky#readme, but I assume any other pre-commit hook will work.

help wanted

All 7 comments

I'm on it.

Added a basic implementation for bypassing failed git hooks (using --no-verify flag). Also added this rule for 3 commands which can fail due to a hook, namely am, commit and, push.

Can @dekelb or someone else please test this, and see if it works as intended.

Thank you.

Seems like it doesn't work (sorry it took some time to test it).

➜  REPO git:(feature/rows-dnd) βœ— git commit demo/demo.js -m "working example"
husky > pre-commit (node v13.11.0)
....
....
βœ– 5 problems (5 errors, 0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] eslint: `eslint src/** -c ./configs/.eslintrc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] eslint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/{me}/.npm/_logs/2020-06-02T22_51_40_019Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: `npm run eslint && npm run tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/{me}/.npm/_logs/2020-06-02T22_51_40_036Z-debug.log
husky > pre-commit hook failed (add --no-verify to bypass)
➜  REPO git:(feature/rows-dnd) βœ— fuck -y
​​​​​​​​​​git commit --amend
husky > pre-commit (node v13.11.0)
....
....
βœ– 5 problems (5 errors, 0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] eslint: `eslint src/** -c ./configs/.eslintrc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] eslint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/{me}/.npm/_logs/2020-06-02T22_51_48_141Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] lint: `npm run eslint && npm run tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/{me}/.npm/_logs/2020-06-02T22_51_48_158Z-debug.log
husky > pre-commit hook failed (add --no-verify to bypass)

Regarding what I'm actually expecting here - since the command was git commit demo/demo.js -m "working example" the expected behaviour would be git commit demo/demo.js -m "working example" --no-verify

fuck -y wouldn't work in this case. The response from a pre-commit hook may take way too long to produce useful output. Hence, this rule has to be output-independent. But then, it should have a lower priority, which would throw it to the back of the queue of suggestions.

Agreed @scorphus, these hooks can take a long time to execute. Will incorporate the changes you suggested.

I'll try to complete the PR asap. I'm a little busy right now.

@scorphus I think this was resolved with #1097 and should be closed.

Thanks for contributing, @divykj <3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cuwaters picture cuwaters  Β·  4Comments

zixuanweeei picture zixuanweeei  Β·  5Comments

sbrl picture sbrl  Β·  3Comments

jabbson picture jabbson  Β·  4Comments

onewheelskyward picture onewheelskyward  Β·  3Comments