feat(hooks): support interactive hook scripts by PhilipNelson5 · Pull Request #1925 · commitizen-tools/commitizen · GitHub
Skip to content

feat(hooks): support interactive hook scripts#1925

Open
PhilipNelson5 wants to merge 2 commits intocommitizen-tools:masterfrom
PhilipNelson5:feat/interactive-hooks
Open

feat(hooks): support interactive hook scripts#1925
PhilipNelson5 wants to merge 2 commits intocommitizen-tools:masterfrom
PhilipNelson5:feat/interactive-hooks

Conversation

@PhilipNelson5
Copy link
Copy Markdown
Contributor

@PhilipNelson5 PhilipNelson5 commented Apr 6, 2026

Description

When a pre/post bump hook needs user input it fails because stdin, stdout, and stderr are redirected. This feature adds a new cmd utility to run a command without capturing/redirecting input or output to the subprocess. This allows interactive hooks to request input and display output to the user interactively.

Checklist

Was generative AI tooling used to co-author this PR?

  • Yes (please specify the tool below)

Code Changes

  • Add test cases to all the changes you introduce
  • Run uv run poe all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run uv run poe doc locally to ensure the documentation pages renders correctly
  • Check and fix any broken links (internal or external)

Expected Behavior

When a pre/post bump hook tries to get user input, it successfully does so.

Steps to Test This Pull Request

  1. configure a pre/post bump hook which prompts the user for input.
  2. run cz bump.
  3. the hook successfully requests user input and is able to capture it without issue.

Additional Context

@PhilipNelson5 PhilipNelson5 changed the title feat(hooks): support interactive hooks scripts feat(hooks): support interactive hook scripts Apr 6, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 6, 2026

@PhilipNelson5 PhilipNelson5 force-pushed the feat/interactive-hooks branch 3 times, most recently from 98d622f to 8746afc Compare April 6, 2026 21:51
Comment thread tests/test_bump_hooks.py
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Then how should we test the cmd.run? Is the test for that removed?

Copy link
Copy Markdown
Contributor Author

@PhilipNelson5 PhilipNelson5 Apr 12, 2026

Choose a reason for hiding this comment

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

I'm not aware of the project history. I don't know if it was ever tested.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I see. I just misunderstood what the test test_run does here.

@bearomorphism
Copy link
Copy Markdown
Collaborator

Please fix the coverage pipeline, thanks

@PhilipNelson5
Copy link
Copy Markdown
Contributor Author

@bearomorphism I added tests for cmd.run and cmd.run_interactive.

@PhilipNelson5 PhilipNelson5 force-pushed the feat/interactive-hooks branch from da45b62 to d483e68 Compare April 13, 2026 14:18
@bearomorphism
Copy link
Copy Markdown
Collaborator

Thank you for fixing the pipeline failures! @PhilipNelson5

@woile please review this feature

Comment thread commitizen/cmd.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

According to #1918 using shell=True is a security issue if True, should we remove it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just removing shell=True causes 100 failed tests and 296 errors. It's probably outside the scope of this PR to fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants