From 38b7861708ec1f108770643af7615175b8b061ed Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 1 Jul 2020 10:16:57 +0800 Subject: [PATCH 1/5] ci: rename lint as reformat --- .github/pull_request_template.md | 2 +- docs/contributing.md | 2 +- scripts/{lint => reformat} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename scripts/{lint => reformat} (100%) 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/docs/contributing.md b/docs/contributing.md index dfbf2a9c7f..f835b5f713 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -15,6 +15,6 @@ If you're a first-time contributor, you can check the issues with [good first is 5. 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. +7. Run `./scripts/reformat` 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) 🙏 diff --git a/scripts/lint b/scripts/reformat similarity index 100% rename from scripts/lint rename to scripts/reformat From 774c3f850186bff49edbaf25cb885430037195c1 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 1 Jul 2020 10:17:13 +0800 Subject: [PATCH 2/5] ci(pre-commit): add pre-commit-config --- .pre-commit-config.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..89803b65e2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +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: 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] From 7029c08476576b80ab277de49db238a5f5c3aefe Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 1 Jul 2020 10:17:34 +0800 Subject: [PATCH 3/5] style: fix eof and trailing spaces --- .codacy.yaml | 2 +- .github/workflows/pythonpublish.yaml | 1 - LICENSE | 2 +- .../cz/conventional_commits/conventional_commits_info.txt | 2 +- docs/README.md | 2 ++ pyproject.toml | 1 - 6 files changed, 5 insertions(+), 5 deletions(-) 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/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/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/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" - From 89df39e97d737338d9b39b283acb9de00a3cdb87 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 1 Jul 2020 10:23:35 +0800 Subject: [PATCH 4/5] docs(contributing): add pre-commit setup --- docs/contributing.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/contributing.md b/docs/contributing.md index f835b5f713..7973530a92 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`) +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/reformat` 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) 🙏 From 4fddcbea44f931864b070b6f1915a175246c2eee Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Wed, 1 Jul 2020 10:30:23 +0800 Subject: [PATCH 5/5] ci(pre-commit): add commitizen to pre-commit config --- .pre-commit-config.yaml | 7 +++++++ docs/contributing.md | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89803b65e2..c7c755faa9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,13 @@ repos: 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 diff --git a/docs/contributing.md b/docs/contributing.md index 7973530a92..6966229ff1 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -11,7 +11,7 @@ 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. Setup [pre-commit](https://pre-commit.com/) hook (`pre-commit install -t pre-commit -t pre-push`) +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.)