Skip to content
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

feat: Pass errors from pre/post-gen hook(s) to the FailedHookException message #1829

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

vykozlov
Copy link

If cookiecutter functions are called in python code, it is useful to catch possible errors appearing during the execution of cookiecutter pre/post-generate hooks.

modified: cookiecutter/hooks.py to:

  • catch possible errors from the subprocess calling hook scripts
  • add these errors in the FailedHookException message

The change is not breaking, all tests run to 100% coverage

Co-authored-by: vykozlov

valentin.kozlov added 2 commits March 31, 2023 17:39
…xception message

If cookiecutter functions are called in python code, it is useful to catch possible errors appearing during the execution of cookiecutter pre/post-generate hooks.

modified:   cookiecutter/hooks.py to:

* catch possible errors from the subprocess calling hook scripts
* add these errors in the FailedHookException message

The change is not breaking, all tests run to 100% coverage

Co-authored-by: vykozlov
modified:

* ../.pre-commit-config.yaml : "gitlab.com/com/pycqa/flake8" => github.com/pycqa/flake8 as the repo at "gitlab.com" does not exist
* hooks.py : to comply with pep8
Copy link
Member

@kurtmckee kurtmckee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vykozlov I've left feedback. Thanks for your work on this!

Would you add a test to demonstrate this new feature?

.pre-commit-config.yaml Outdated Show resolved Hide resolved
cookiecutter/hooks.py Outdated Show resolved Hide resolved
cookiecutter/hooks.py Outdated Show resolved Hide resolved
cookiecutter/hooks.py Show resolved Hide resolved
@ericof ericof added the bug This issue/PR relates to a bug. label Jun 13, 2023
@ericof ericof added this to the 2.2.0 milestone Jun 13, 2023
Copy link
Member

@ericof ericof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ericof ericof added enhancement This issue/PR relates to a feature request. and removed bug This issue/PR relates to a bug. labels Jun 13, 2023
Copy link
Member

@ericof ericof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vykozlov Could you please add a test?

@ericof ericof modified the milestones: 2.2.0, 3.0.0 Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue/PR relates to a feature request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants