Skip to content

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
merged 2 commits into from
Aug 22, 2022

Conversation

Kurt-von-Laven
Copy link
Contributor

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

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.

@codecov
Copy link

codecov bot commented Aug 21, 2022

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).
@Kurt-von-Laven
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

@Lee-W Lee-W merged commit 8cb1e22 into commitizen-tools:master Aug 22, 2022
@Kurt-von-Laven Kurt-von-Laven deleted the pre-commit branch August 23, 2022 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants