diff --git a/.codacy.yaml b/.codacy.yaml index 3a31bdb7be..cab97400c0 100644 --- a/.codacy.yaml +++ b/.codacy.yaml @@ -1,3 +1,3 @@ exclude_paths: - 'tests/**' - - 'docs/**' \ No newline at end of file + - 'docs/**' diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 82d423a897..579cb681b7 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -15,7 +15,7 @@ Please put an `x` in the box that applies ## 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 +- [ ] Run `./script/reformat` 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 diff --git a/.github/workflows/pythonpublish.yaml b/.github/workflows/pythonpublish.yaml index 937d6aa387..2a827518cc 100644 --- a/.github/workflows/pythonpublish.yaml +++ b/.github/workflows/pythonpublish.yaml @@ -28,4 +28,3 @@ jobs: PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | ./scripts/publish - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..c7c755faa9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +default_stages: [push] +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.1.0 + hooks: + - id: check-vcs-permalinks + - id: end-of-file-fixer + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - id: debug-statements + - id: no-commit-to-branch + + - repo: https://github.com/Woile/commitizen + rev: v1.23.0 + hooks: + - id: commitizen + stages: [commit-msg] + + - repo: local + hooks: + - id: reformat + name: reformat + language: system + pass_filenames: false + entry: ./scripts/reformat + types: [python] + + - id: linter and test + name: linter and test + language: system + pass_filenames: false + entry: ./scripts/test + types: [python] diff --git a/LICENSE b/LICENSE index 881035d1d0..05cf267ae5 100644 --- a/LICENSE +++ b/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/commitizen/cz/conventional_commits/conventional_commits_info.txt b/commitizen/cz/conventional_commits/conventional_commits_info.txt index f1b5633e07..a076e4f5ec 100644 --- a/commitizen/cz/conventional_commits/conventional_commits_info.txt +++ b/commitizen/cz/conventional_commits/conventional_commits_info.txt @@ -28,4 +28,4 @@ information and is contained within parenthesis, e.g., feat(parser): add ability [optional body] -[optional footer] \ No newline at end of file +[optional footer] diff --git a/docs/README.md b/docs/README.md index 348bb62e43..718f663580 100644 --- a/docs/README.md +++ b/docs/README.md @@ -77,6 +77,7 @@ cz c ### 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 --- repos: @@ -86,6 +87,7 @@ repos: - id: commitizen stages: [commit-msg] ``` + Read more about the `check` command [here](https://commitizen-tools.github.io/commitizen/check/). ### Help diff --git a/docs/contributing.md b/docs/contributing.md index dfbf2a9c7f..6966229ff1 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -11,10 +11,11 @@ If you're a first-time contributor, you can check the issues with [good first is 1. Fork [the repository](https://github.com/commitizen-tools/commitizen). 2. Clone the repository from your GitHub. 3. Setup development environment through [poetry](https://python-poetry.org/) (`poetry install`). -4. Check out a new branch and add your modification. -5. Add test cases for all your changes. +4. Setup [pre-commit](https://pre-commit.com/) hook (`pre-commit install -t pre-commit -t pre-push -t commit-msg`) +5. Check out a new branch and add your modification. +6. Add test cases for all your changes. (We use [CodeCov](https://codecov.io/) to ensure our test coverage does not drop.) -6. Use [commitizen](https://github.com/commitizen-tools/commitizen) to do git commit. -7. Run `./scripts/lint` and `./scripts/test` to ensure you follow the coding style and the tests pass. -8. Update `READMD.md` and `CHANGELOG.md` for your changes. -9. Send a [pull request](https://github.com/commitizen-tools/commitizen/pulls) 🙏 +7. Use [commitizen](https://github.com/commitizen-tools/commitizen) to do git commit. +8. Run `./scripts/reformat` and `./scripts/test` to ensure you follow the coding style and the tests pass. +9. Update `READMD.md` and `CHANGELOG.md` for your changes. +10. Send a [pull request](https://github.com/commitizen-tools/commitizen/pulls) 🙏 diff --git a/pyproject.toml b/pyproject.toml index 8b897d24e6..2acc6c6d83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,4 +109,3 @@ line_length = 88 [build-system] requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" - diff --git a/scripts/lint b/scripts/reformat similarity index 100% rename from scripts/lint rename to scripts/reformat