poetry-plugin-export
poetry-plugin-export copied to clipboard
poetry-export pre-commit hook doesn't fail
The poetry-expory hook is quite useful but shouldn't it return an error when it actually detects any changes? I want to use it alongside poetry-lock hook which does in fact fails after updating the lock file, and forces you to commit the changed lock file. I basically want to make sure that the poetry.lock and requirements.txt files are always in sync when commits are pushed. Right now the poetry-export does correctly update requirements.txt but doesn't block the push.
(sorry for the duplicate, I just realised poetry export has its own repo)
Are you running pre-commit run --all-files
? This may not be a poetry
or poetry-export
problem, but a pre-commit
problem.
For specific details, please refer to this code: https://github.com/pre-commit/pre-commit/blob/48f0dc9615488b583b11f2d90bd4a332701c6b6a/pre_commit/git.py#L154-L155, which means the implementation of pre-commit
, a new, unstaged file will not be in all_files
, so the poetry-export
hook cannot detect poetry.lock
. This problem does not exist if you have committed the poetry.lock
file before, or if you did not execute pre-commit
in the form of pre-commit run --all-files
.
One possible workaround is for you to manually stage poetry.lock
and execute pre-commit run --all-files
again. This works for me.
My poetry.lock
or requirements.txt
are not new files and I'm not running with --all-files
. I think the problem is in this line:
i.e. this plugin returns success unconditionally. I'd like to have the behaviour of poetry-lock hook so that if requirements.txt
changes and it is not staged the command returns a non-zero error.