Skip to content

Precommit docs #210

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 4 commits into from
Jul 1, 2020
Merged

Precommit docs #210

merged 4 commits into from
Jul 1, 2020

Conversation

alecgerona
Copy link
Contributor

Types of changes

Please put an x in the box that applies

  • Bugfix
  • New feature
  • Refactoring
  • Breaking change (any change that would cause existing functionality to not work as expected)
  • Documentation Update
  • Other (please describe)

Description

Add instructions for pre-commit integration in the README.md itself.

Checklist:

  • Add test cases to all the changes you introduce
  • Run ./script/lint and ./script/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

Related Issue

#196 #209

@codecov
Copy link

codecov bot commented Jun 27, 2020

Codecov Report

Merging #210 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #210   +/-   ##
=======================================
  Coverage   95.64%   95.64%           
=======================================
  Files          34       34           
  Lines         942      942           
=======================================
  Hits          901      901           
  Misses         41       41           
Flag Coverage Δ
#unittests 95.64% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b2d4558...2f76fe9. Read the comment docs.

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.

Thanks for your contribution! I've added some comments.

### Integrating with Pre-commit
Commitizen can lint your commit message for you with `cz check`.
You can integrate this in your [pre-commit](https://pre-commit.com/) config with:
```yaml
Copy link
Member

Choose a reason for hiding this comment

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

Adding this config file is not enough for pre-commit, I'd suggest add the pre-commit install --hook-type commit-msg command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. This already assumes that the dev has run pre-commit before tho. When I was trying this out for myself I just added that snippet to my config and reran pre-commit. I think the stages: [commit-msg] is enough.

Copy link
Member

Choose a reason for hiding this comment

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

By default commit-msg is not set for pre-commit. Simply adding these lines to your .pre-commit-config.yaml will not trigger pre-commit at commit-msg stage.

The following is how I test it.

e.g.,

mkdir test-project
cd test-project
git init
# add a .pre-commit-config.yaml without commitizen
git add .
git commit
pre-commit install
# add commitizen config to .pre-commit-config.yaml
git add .
git commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @Lee-W, just to follow up, you're right. It needs the pre-commit install --hook-type commit-msg command.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I miss this part when I merged this PR. No worries. I'll add it in another PR.

@alecgerona alecgerona requested a review from Lee-W June 30, 2020 07:44
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.

Thanks for the update 🙂 We have one more discussion to resolve and then we can merge it.

### Integrating with Pre-commit
Commitizen can lint your commit message for you with `cz check`.
You can integrate this in your [pre-commit](https://pre-commit.com/) config with:
```yaml
Copy link
Member

Choose a reason for hiding this comment

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

By default commit-msg is not set for pre-commit. Simply adding these lines to your .pre-commit-config.yaml will not trigger pre-commit at commit-msg stage.

The following is how I test it.

e.g.,

mkdir test-project
cd test-project
git init
# add a .pre-commit-config.yaml without commitizen
git add .
git commit
pre-commit install
# add commitizen config to .pre-commit-config.yaml
git add .
git commit

@woile
Copy link
Member

woile commented Jun 30, 2020

Can't we add to pyproject.toml

version_files = [
  "pyproject.toml:version",
  "commitizen/__version__.py",
  "docs/README.md:\trev:"
]

or something like that?

@alecgerona
Copy link
Contributor Author

alecgerona commented Jun 30, 2020

Can't we add to pyproject.toml

version_files = [
  "pyproject.toml:version",
  "commitizen/__version__.py",
  "docs/README.md:\trev:"
]

or something like that?

Sure. But I think it'll just make it more verbose than it has to be. Other python libs that use pre-commit—pre-commit included just use master or stable.

@woile
Copy link
Member

woile commented Jun 30, 2020

master is fine by me as well, I have no issues with it

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.

3 participants