Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Self Check With New commitizen-branch pre-commit Hook #565

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

Merged
Lee-W merged 2 commits into commitizen-tools:master from Kurt-von-Laven:pre-commit
Aug 22, 2022

Conversation

Copy link
Contributor

@Kurt-von-Laven Kurt-von-Laven commented Aug 21, 2022
edited
Loading

Description

Check existing commit messages. Use new commitizen-branch hook to verify correctness of existing commit messages post-commit and pre-push. This guards against cherry-picked commits with invalid commit messages as well as empty commit messages (e.g., created with git commit --allow-empty-message).

Run hooks pre-commit by default. They already run pre-push, and this behavior is left unchanged. Running hooks pre-commit gives developers more immediate feedback and improves commit quality by blocking an often unnecessary series of fix commits.

When testing this change locally, poetry install failed with the following error:

Creating virtualenv commitizen-9emEp_2F-py3.10 in ~/.cache/pypoetry/virtualenvs
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.
 SolverProblemError
 Because commitizen depends on charset-normalizer (^2.1.0) which doesn't match any versions, version solving failed.
 at ~/.asdf/installs/poetry/1.1.14/lib/poetry/puzzle/solver.py:241 in _solve
 237│ packages = result.packages
 238│ except OverrideNeeded as e:
 239│ return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
 240│ except SolveFailure as e:
 → 241│ raise SolverProblemError(e)
 242│ 
 243│ results = dict(
 244│ depth_first_search(
 245│ PackageNode(self._package, packages), aggregate_package_nodes

I think poetry update may need to be run, but when I tried that, I encountered 51 test failures.

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

The new commitizen-branch hook passes.

Steps to Test This Pull Request

  1. Run poetry update to work around issue described above.
  2. Run poetry install to install pre-commit and other dependencies.
  3. Make a test commit since presently the commitizen-branch hook fails when the range origin/HEAD..HEAD contains no commits.
  4. Run poetry run pre-commit run --all-files --hook-stage push to run all pre-push hooks.

Additional context

Follows on #517.

Lee-W and nvuillam reacted with thumbs up emoji
Copy link

codecov bot commented Aug 21, 2022
edited
Loading

Codecov Report

Base: 98.43% // Head: 98.37% // Decreases project coverage by -0.06% ⚠️

Coverage data is based on head (f65da26) compared to base (f093717).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@ Coverage Diff @@
## master #565 +/- ##
==========================================
- Coverage 98.43% 98.37% -0.07% 
==========================================
 Files 39 39 
 Lines 1602 1602 
==========================================
- Hits 1577 1576 -1 
- Misses 25 26 +1 
Flag Coverage Δ
unittests 98.37% <100.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
commitizen/__version__.py 100.00% <100.00%> (ø)
commitizen/changelog.py 99.43% <0.00%> (-0.57%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

They already run pre-push, and this behavior is left unchanged. Running
hooks pre-commit gives developers more immediate feedback and improves
commit quality by blocking an often unnecessary series of fix commits.
Use new commitizen-branch hook to verify correctness of existing commit
messages post-commit and pre-push. This guards against cherry-picked
commits with invalid commit messages as well as empty commit messages
(e.g., created with git commit --allow-empty-message).
Copy link
Contributor Author

The Codecov issue strikes me as test flakiness.

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @Kurt-von-Laven Let's merge it

Kurt-von-Laven reacted with hooray emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@Lee-W Lee-W Lee-W approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /