conventional-pre-commit 2.4.0__tar.gz → 3.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- conventional_pre_commit-3.1.0/.devcontainer/Dockerfile +21 -0
- conventional_pre_commit-3.1.0/.devcontainer/compose.yml +10 -0
- conventional_pre_commit-3.1.0/.devcontainer/devcontainer.json +31 -0
- conventional_pre_commit-3.1.0/.dockerignore +1 -0
- conventional_pre_commit-3.1.0/.flake8 +2 -0
- conventional_pre_commit-3.1.0/.github/dependabot.yaml +27 -0
- conventional_pre_commit-3.1.0/.github/workflows/release.yml +62 -0
- conventional_pre_commit-3.1.0/.github/workflows/tests.yml +51 -0
- conventional_pre_commit-3.1.0/.gitignore +4 -0
- conventional_pre_commit-3.1.0/.pre-commit-config.yaml +53 -0
- conventional_pre_commit-3.1.0/.pre-commit-hooks.yaml +7 -0
- conventional_pre_commit-3.1.0/.vscode/settings.json +16 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/PKG-INFO +58 -20
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/README.md +48 -17
- conventional_pre_commit-3.1.0/conventional_pre_commit/__init__.py +7 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit/format.py +27 -7
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit/hook.py +12 -3
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit.egg-info/PKG-INFO +59 -21
- conventional_pre_commit-3.1.0/conventional_pre_commit.egg-info/SOURCES.txt +38 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit.egg-info/requires.txt +2 -1
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/pyproject.toml +19 -4
- conventional_pre_commit-3.1.0/tests/conftest.py +54 -0
- conventional_pre_commit-3.1.0/tests/messages/bad_commit +1 -0
- conventional_pre_commit-3.1.0/tests/messages/conventional_commit +1 -0
- conventional_pre_commit-3.1.0/tests/messages/conventional_commit_bad_multi_line +2 -0
- conventional_pre_commit-3.1.0/tests/messages/conventional_commit_gbk +1 -0
- conventional_pre_commit-3.1.0/tests/messages/conventional_commit_multi_line +3 -0
- conventional_pre_commit-3.1.0/tests/messages/conventional_commit_utf-8 +1 -0
- conventional_pre_commit-3.1.0/tests/messages/conventional_commit_with_scope +1 -0
- conventional_pre_commit-3.1.0/tests/messages/custom_commit +1 -0
- conventional_pre_commit-3.1.0/tests/messages/fixup_commit +1 -0
- conventional_pre_commit-3.1.0/tests/run.sh +11 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/tests/test_format.py +64 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/tests/test_hook.py +65 -17
- conventional_pre_commit-2.4.0/conventional_pre_commit.egg-info/SOURCES.txt +0 -14
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/LICENSE +0 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit.egg-info/dependency_links.txt +0 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit.egg-info/entry_points.txt +0 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit.egg-info/top_level.txt +0 -0
- {conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/setup.cfg +0 -0
- {conventional_pre_commit-2.4.0/conventional_pre_commit → conventional_pre_commit-3.1.0/tests}/__init__.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
FROM python:3.11
|
|
2
|
+
|
|
3
|
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
4
|
+
PYTHONUNBUFFERED=1 \
|
|
5
|
+
USER=compiler
|
|
6
|
+
|
|
7
|
+
# create $USER and home directory
|
|
8
|
+
RUN useradd --create-home --shell /bin/bash $USER && \
|
|
9
|
+
chown -R $USER /home/$USER
|
|
10
|
+
|
|
11
|
+
# switch to non-root $USER
|
|
12
|
+
USER $USER
|
|
13
|
+
|
|
14
|
+
# enter src directory
|
|
15
|
+
WORKDIR /home/$USER/src
|
|
16
|
+
|
|
17
|
+
# update PATH for local pip installs
|
|
18
|
+
ENV PATH "$PATH:/home/$USER/.local/bin"
|
|
19
|
+
|
|
20
|
+
# update pip
|
|
21
|
+
RUN python -m pip install --upgrade pip
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "compilerla/conventional-pre-commit",
|
|
3
|
+
"dockerComposeFile": ["./compose.yml"],
|
|
4
|
+
"service": "dev",
|
|
5
|
+
"runServices": ["dev"],
|
|
6
|
+
"workspaceFolder": "/home/compiler/src",
|
|
7
|
+
"postCreateCommand": "pip install -e .[dev]",
|
|
8
|
+
"customizations": {
|
|
9
|
+
"vscode": {
|
|
10
|
+
// Set *default* container specific settings.json values on container create.
|
|
11
|
+
"settings": {
|
|
12
|
+
"terminal.integrated.defaultProfile.linux": "bash",
|
|
13
|
+
"terminal.integrated.profiles.linux": {
|
|
14
|
+
"bash": {
|
|
15
|
+
"path": "/bin/bash"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
// Add the IDs of extensions you want installed when the container is created.
|
|
20
|
+
"extensions": [
|
|
21
|
+
"eamodio.gitlens",
|
|
22
|
+
"esbenp.prettier-vscode",
|
|
23
|
+
"mhutchie.git-graph",
|
|
24
|
+
"ms-python.python",
|
|
25
|
+
"ms-python.black-formatter",
|
|
26
|
+
"ms-python.flake8",
|
|
27
|
+
"tamasfe.even-better-toml"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.egg-info
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "pip"
|
|
9
|
+
directory: "/" # pyproject.toml
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "daily"
|
|
12
|
+
commit-message:
|
|
13
|
+
prefix: "chore"
|
|
14
|
+
include: "scope"
|
|
15
|
+
labels:
|
|
16
|
+
- "dependencies"
|
|
17
|
+
- package-ecosystem: "github-actions"
|
|
18
|
+
# Workflow files stored in the
|
|
19
|
+
# default location of `.github/workflows`
|
|
20
|
+
directory: "/"
|
|
21
|
+
schedule:
|
|
22
|
+
interval: "daily"
|
|
23
|
+
commit-message:
|
|
24
|
+
prefix: "chore"
|
|
25
|
+
include: "scope"
|
|
26
|
+
labels:
|
|
27
|
+
- "dependencies"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: Release to GitHub and PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
tags:
|
|
7
|
+
- "v[2-9].[0-9]+.[0-9]+"
|
|
8
|
+
- "v[2-9].[0-9]+.[0-9]+-pre[0-9]?"
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
uses: ./.github/workflows/tests.yml
|
|
13
|
+
|
|
14
|
+
release:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
environment: release
|
|
17
|
+
needs: test
|
|
18
|
+
permissions:
|
|
19
|
+
# https://github.com/softprops/action-gh-release#permissions
|
|
20
|
+
contents: write
|
|
21
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
22
|
+
id-token: write
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- uses: actions/setup-python@v5
|
|
28
|
+
with:
|
|
29
|
+
python-version: "3.11"
|
|
30
|
+
cache: pip
|
|
31
|
+
cache-dependency-path: "**/pyproject.toml"
|
|
32
|
+
|
|
33
|
+
- name: Install build dependencies
|
|
34
|
+
run: pip install build
|
|
35
|
+
|
|
36
|
+
- name: Build package
|
|
37
|
+
run: python -m build
|
|
38
|
+
|
|
39
|
+
- name: Release
|
|
40
|
+
id: release
|
|
41
|
+
uses: softprops/action-gh-release@v1
|
|
42
|
+
with:
|
|
43
|
+
files: |
|
|
44
|
+
./dist/*.whl
|
|
45
|
+
./dist/*.tar.gz
|
|
46
|
+
prerelease: ${{ contains(github.ref, '-pre') }}
|
|
47
|
+
generate_release_notes: ${{ !contains(github.ref, '-pre') }}
|
|
48
|
+
|
|
49
|
+
- name: Publish to Test PyPI
|
|
50
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
51
|
+
if: ${{ contains(github.ref, '-pre') }}
|
|
52
|
+
with:
|
|
53
|
+
repository-url: https://test.pypi.org/legacy/
|
|
54
|
+
print-hash: true
|
|
55
|
+
skip-existing: true
|
|
56
|
+
verbose: true
|
|
57
|
+
|
|
58
|
+
- name: Publish to PyPI
|
|
59
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
60
|
+
if: ${{ !contains(github.ref, '-pre') }}
|
|
61
|
+
with:
|
|
62
|
+
print-hash: true
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- "main"
|
|
8
|
+
workflow_call:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
tests:
|
|
12
|
+
name: Tests
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
# Gives the action the necessary permissions for publishing new
|
|
16
|
+
# comments in pull requests.
|
|
17
|
+
pull-requests: write
|
|
18
|
+
# Gives the action the necessary permissions for pushing data to the
|
|
19
|
+
# python-coverage-comment-action branch, and for editing existing
|
|
20
|
+
# comments (to avoid publishing multiple comments in the same PR)
|
|
21
|
+
contents: write
|
|
22
|
+
|
|
23
|
+
strategy:
|
|
24
|
+
matrix:
|
|
25
|
+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
31
|
+
uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version: ${{ matrix.python-version }}
|
|
34
|
+
cache: pip
|
|
35
|
+
cache-dependency-path: "**/pyproject.toml"
|
|
36
|
+
|
|
37
|
+
- name: Install dependencies
|
|
38
|
+
run: |
|
|
39
|
+
python -m pip install --upgrade pip
|
|
40
|
+
pip install -e .[dev]
|
|
41
|
+
|
|
42
|
+
- name: Run tests
|
|
43
|
+
run: ./tests/run.sh
|
|
44
|
+
|
|
45
|
+
- name: Coverage comment
|
|
46
|
+
uses: py-cov-action/python-coverage-comment-action@v3
|
|
47
|
+
if: github.event_name != 'workflow_call' && matrix.python-version == '3.11'
|
|
48
|
+
with:
|
|
49
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
50
|
+
MINIMUM_GREEN: 90
|
|
51
|
+
MINIMUM_ORANGE: 80
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
ci:
|
|
2
|
+
autofix_commit_msg: "chore(pre-commit): autofix run"
|
|
3
|
+
autoupdate_commit_msg: "chore(pre-commit): autoupdate hooks"
|
|
4
|
+
|
|
5
|
+
default_install_hook_types:
|
|
6
|
+
- pre-commit
|
|
7
|
+
- commit-msg
|
|
8
|
+
|
|
9
|
+
repos:
|
|
10
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
11
|
+
rev: v4.5.0
|
|
12
|
+
hooks:
|
|
13
|
+
- id: trailing-whitespace
|
|
14
|
+
- id: mixed-line-ending
|
|
15
|
+
- id: end-of-file-fixer
|
|
16
|
+
- id: requirements-txt-fixer
|
|
17
|
+
- id: check-yaml
|
|
18
|
+
- id: check-added-large-files
|
|
19
|
+
|
|
20
|
+
- repo: https://github.com/psf/black
|
|
21
|
+
rev: 23.12.1
|
|
22
|
+
hooks:
|
|
23
|
+
- id: black
|
|
24
|
+
types:
|
|
25
|
+
- python
|
|
26
|
+
|
|
27
|
+
- repo: https://github.com/PyCQA/flake8
|
|
28
|
+
rev: 7.0.0
|
|
29
|
+
hooks:
|
|
30
|
+
- id: flake8
|
|
31
|
+
types:
|
|
32
|
+
- python
|
|
33
|
+
|
|
34
|
+
- repo: https://github.com/pycqa/bandit
|
|
35
|
+
rev: 1.7.6
|
|
36
|
+
hooks:
|
|
37
|
+
- id: bandit
|
|
38
|
+
args: ["-ll"]
|
|
39
|
+
files: .py$
|
|
40
|
+
|
|
41
|
+
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
42
|
+
rev: v4.0.0-alpha.8
|
|
43
|
+
hooks:
|
|
44
|
+
- id: prettier
|
|
45
|
+
types_or: [javascript]
|
|
46
|
+
|
|
47
|
+
- repo: local
|
|
48
|
+
hooks:
|
|
49
|
+
- id: conventional-pre-commit
|
|
50
|
+
name: Conventional Commit (local)
|
|
51
|
+
entry: conventional-pre-commit
|
|
52
|
+
language: python
|
|
53
|
+
stages: [commit-msg]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.formatOnSave": true,
|
|
3
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
4
|
+
"files.encoding": "utf8",
|
|
5
|
+
"files.eol": "\n",
|
|
6
|
+
"files.insertFinalNewline": true,
|
|
7
|
+
"files.trimFinalNewlines": true,
|
|
8
|
+
"files.trimTrailingWhitespace": true,
|
|
9
|
+
"[python]": {
|
|
10
|
+
"editor.defaultFormatter": "ms-python.black-formatter"
|
|
11
|
+
},
|
|
12
|
+
"python.languageServer": "Pylance",
|
|
13
|
+
"python.testing.pytestArgs": ["tests"],
|
|
14
|
+
"python.testing.pytestEnabled": true,
|
|
15
|
+
"python.testing.unittestEnabled": false
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: conventional_pre_commit
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.1.0
|
|
4
4
|
Summary: A pre-commit hook that checks commit messages for Conventional Commits formatting.
|
|
5
5
|
Author-email: Compiler LLC <dev@compiler.la>
|
|
6
6
|
License: Apache License
|
|
@@ -209,16 +209,25 @@ Project-URL: code, https://github.com/compilerla/conventional-pre-commit
|
|
|
209
209
|
Project-URL: tracker, https://github.com/compilerla/conventional-pre-commit/issues
|
|
210
210
|
Keywords: git,pre-commit,conventional-commits
|
|
211
211
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
212
|
-
Requires-Python: >=3.
|
|
212
|
+
Requires-Python: >=3.8
|
|
213
213
|
Description-Content-Type: text/markdown
|
|
214
|
-
Provides-Extra: dev
|
|
215
214
|
License-File: LICENSE
|
|
215
|
+
Provides-Extra: dev
|
|
216
|
+
Requires-Dist: black; extra == "dev"
|
|
217
|
+
Requires-Dist: build; extra == "dev"
|
|
218
|
+
Requires-Dist: coverage; extra == "dev"
|
|
219
|
+
Requires-Dist: flake8; extra == "dev"
|
|
220
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
221
|
+
Requires-Dist: pytest; extra == "dev"
|
|
222
|
+
Requires-Dist: setuptools_scm; extra == "dev"
|
|
216
223
|
|
|
217
224
|
# conventional-pre-commit
|
|
218
225
|
|
|
219
226
|
A [`pre-commit`](https://pre-commit.com) hook to check commit messages for
|
|
220
227
|
[Conventional Commits](https://conventionalcommits.org) formatting.
|
|
221
228
|
|
|
229
|
+
Works with Python >= 3.8.
|
|
230
|
+
|
|
222
231
|
## Usage
|
|
223
232
|
|
|
224
233
|
Make sure `pre-commit` is [installed](https://pre-commit.com#install).
|
|
@@ -240,7 +249,7 @@ repos:
|
|
|
240
249
|
hooks:
|
|
241
250
|
- id: conventional-pre-commit
|
|
242
251
|
stages: [commit-msg]
|
|
243
|
-
args: []
|
|
252
|
+
args: []
|
|
244
253
|
```
|
|
245
254
|
|
|
246
255
|
Install the `pre-commit` script:
|
|
@@ -278,9 +287,15 @@ Example commit message fixing an issue:
|
|
|
278
287
|
|
|
279
288
|
fix: remove infinite loop
|
|
280
289
|
|
|
281
|
-
|
|
290
|
+
Example commit with scope in parentheses after the type for more context:
|
|
282
291
|
|
|
283
292
|
fix(account): remove infinite loop
|
|
293
|
+
|
|
294
|
+
Example commit with a body:
|
|
295
|
+
|
|
296
|
+
fix: remove infinite loop
|
|
297
|
+
|
|
298
|
+
Additional information on the issue caused by the infinite loop
|
|
284
299
|
```
|
|
285
300
|
|
|
286
301
|
Make a (conventional) commit :heavy_check_mark::
|
|
@@ -331,6 +346,40 @@ print(is_conventional("nope: this is not a conventional commit"))
|
|
|
331
346
|
print(is_conventional("custom: this is a conventional commit", types=["custom"]))
|
|
332
347
|
```
|
|
333
348
|
|
|
349
|
+
## Passing `args`
|
|
350
|
+
|
|
351
|
+
`conventional-pre-commit` supports a number of arguments to configure behavior:
|
|
352
|
+
|
|
353
|
+
```shell
|
|
354
|
+
$ conventional-pre-commit -h
|
|
355
|
+
usage: conventional-pre-commit [-h] [--force-scope] [--strict] [types ...] input
|
|
356
|
+
|
|
357
|
+
Check a git commit message for Conventional Commits formatting.
|
|
358
|
+
|
|
359
|
+
positional arguments:
|
|
360
|
+
types Optional list of types to support
|
|
361
|
+
input A file containing a git commit message
|
|
362
|
+
|
|
363
|
+
options:
|
|
364
|
+
-h, --help show this help message and exit
|
|
365
|
+
--force-scope Force commit to have scope defined.
|
|
366
|
+
--strict Force commit to strictly follow Conventional Commits formatting. Disallows fixup! style commits.
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Supply arguments on the command-line, or via the pre-commit `hooks.args` property:
|
|
370
|
+
|
|
371
|
+
```yaml
|
|
372
|
+
repos:
|
|
373
|
+
- repo: https://github.com/compilerla/conventional-pre-commit
|
|
374
|
+
rev: <git sha or tag>
|
|
375
|
+
hooks:
|
|
376
|
+
- id: conventional-pre-commit
|
|
377
|
+
stages: [commit-msg]
|
|
378
|
+
args: [--strict, --force-scope, feat, fix, chore, test, custom]
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**NOTE:** when using as a pre-commit hook, `input` is supplied automatically (with the current commit's message).
|
|
382
|
+
|
|
334
383
|
## Development
|
|
335
384
|
|
|
336
385
|
`conventional-pre-commit` comes with a [VS Code devcontainer](https://code.visualstudio.com/learn/develop-cloud/containers)
|
|
@@ -354,22 +403,11 @@ Versioning generally follows [Semantic Versioning](https://semver.org/).
|
|
|
354
403
|
|
|
355
404
|
## Making a release
|
|
356
405
|
|
|
357
|
-
Releases to PyPI are triggered by
|
|
358
|
-
|
|
359
|
-
1. Create a branch `chore/release`
|
|
360
|
-
1. Bump the version in `pyproject.toml`
|
|
361
|
-
1. PR, merge `chore/release` into `main`
|
|
362
|
-
1. Tag `main` with the new version (prefixed by `v`):
|
|
363
|
-
|
|
364
|
-
```bash
|
|
365
|
-
git fetch
|
|
366
|
-
git reset --hard origin/main
|
|
367
|
-
git tag vX.Y.Z
|
|
368
|
-
git push origin vX.Y.Z
|
|
369
|
-
```
|
|
406
|
+
Releases to PyPI and GitHub are triggered by pushing a tag.
|
|
370
407
|
|
|
371
|
-
1.
|
|
372
|
-
1.
|
|
408
|
+
1. Ensure all changes for the release are present in the `main` branch
|
|
409
|
+
1. Tag with the new version: `git tag vX.Y.Z` for regular release, `git tag vX.Y.Z-preN` for pre-release
|
|
410
|
+
1. Push the new version tag: `git push origin vX.Y.Z`
|
|
373
411
|
|
|
374
412
|
## License
|
|
375
413
|
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
A [`pre-commit`](https://pre-commit.com) hook to check commit messages for
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) formatting.
|
|
5
5
|
|
|
6
|
+
Works with Python >= 3.8.
|
|
7
|
+
|
|
6
8
|
## Usage
|
|
7
9
|
|
|
8
10
|
Make sure `pre-commit` is [installed](https://pre-commit.com#install).
|
|
@@ -24,7 +26,7 @@ repos:
|
|
|
24
26
|
hooks:
|
|
25
27
|
- id: conventional-pre-commit
|
|
26
28
|
stages: [commit-msg]
|
|
27
|
-
args: []
|
|
29
|
+
args: []
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
Install the `pre-commit` script:
|
|
@@ -62,9 +64,15 @@ Example commit message fixing an issue:
|
|
|
62
64
|
|
|
63
65
|
fix: remove infinite loop
|
|
64
66
|
|
|
65
|
-
|
|
67
|
+
Example commit with scope in parentheses after the type for more context:
|
|
66
68
|
|
|
67
69
|
fix(account): remove infinite loop
|
|
70
|
+
|
|
71
|
+
Example commit with a body:
|
|
72
|
+
|
|
73
|
+
fix: remove infinite loop
|
|
74
|
+
|
|
75
|
+
Additional information on the issue caused by the infinite loop
|
|
68
76
|
```
|
|
69
77
|
|
|
70
78
|
Make a (conventional) commit :heavy_check_mark::
|
|
@@ -115,6 +123,40 @@ print(is_conventional("nope: this is not a conventional commit"))
|
|
|
115
123
|
print(is_conventional("custom: this is a conventional commit", types=["custom"]))
|
|
116
124
|
```
|
|
117
125
|
|
|
126
|
+
## Passing `args`
|
|
127
|
+
|
|
128
|
+
`conventional-pre-commit` supports a number of arguments to configure behavior:
|
|
129
|
+
|
|
130
|
+
```shell
|
|
131
|
+
$ conventional-pre-commit -h
|
|
132
|
+
usage: conventional-pre-commit [-h] [--force-scope] [--strict] [types ...] input
|
|
133
|
+
|
|
134
|
+
Check a git commit message for Conventional Commits formatting.
|
|
135
|
+
|
|
136
|
+
positional arguments:
|
|
137
|
+
types Optional list of types to support
|
|
138
|
+
input A file containing a git commit message
|
|
139
|
+
|
|
140
|
+
options:
|
|
141
|
+
-h, --help show this help message and exit
|
|
142
|
+
--force-scope Force commit to have scope defined.
|
|
143
|
+
--strict Force commit to strictly follow Conventional Commits formatting. Disallows fixup! style commits.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Supply arguments on the command-line, or via the pre-commit `hooks.args` property:
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
repos:
|
|
150
|
+
- repo: https://github.com/compilerla/conventional-pre-commit
|
|
151
|
+
rev: <git sha or tag>
|
|
152
|
+
hooks:
|
|
153
|
+
- id: conventional-pre-commit
|
|
154
|
+
stages: [commit-msg]
|
|
155
|
+
args: [--strict, --force-scope, feat, fix, chore, test, custom]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**NOTE:** when using as a pre-commit hook, `input` is supplied automatically (with the current commit's message).
|
|
159
|
+
|
|
118
160
|
## Development
|
|
119
161
|
|
|
120
162
|
`conventional-pre-commit` comes with a [VS Code devcontainer](https://code.visualstudio.com/learn/develop-cloud/containers)
|
|
@@ -138,22 +180,11 @@ Versioning generally follows [Semantic Versioning](https://semver.org/).
|
|
|
138
180
|
|
|
139
181
|
## Making a release
|
|
140
182
|
|
|
141
|
-
Releases to PyPI are triggered by
|
|
142
|
-
|
|
143
|
-
1. Create a branch `chore/release`
|
|
144
|
-
1. Bump the version in `pyproject.toml`
|
|
145
|
-
1. PR, merge `chore/release` into `main`
|
|
146
|
-
1. Tag `main` with the new version (prefixed by `v`):
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
git fetch
|
|
150
|
-
git reset --hard origin/main
|
|
151
|
-
git tag vX.Y.Z
|
|
152
|
-
git push origin vX.Y.Z
|
|
153
|
-
```
|
|
183
|
+
Releases to PyPI and GitHub are triggered by pushing a tag.
|
|
154
184
|
|
|
155
|
-
1.
|
|
156
|
-
1.
|
|
185
|
+
1. Ensure all changes for the release are present in the `main` branch
|
|
186
|
+
1. Tag with the new version: `git tag vX.Y.Z` for regular release, `git tag vX.Y.Z-preN` for pre-release
|
|
187
|
+
1. Push the new version tag: `git push origin vX.Y.Z`
|
|
157
188
|
|
|
158
189
|
## License
|
|
159
190
|
|
{conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit/format.py
RENAMED
|
@@ -29,9 +29,9 @@ def r_types(types):
|
|
|
29
29
|
def r_scope(optional=True):
|
|
30
30
|
"""Regex str for an optional (scope)."""
|
|
31
31
|
if optional:
|
|
32
|
-
return r"(\([\w
|
|
32
|
+
return r"(\([\w \/:,-]+\))?"
|
|
33
33
|
else:
|
|
34
|
-
return r"(\([\w
|
|
34
|
+
return r"(\([\w \/:,-]+\))"
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def r_delim():
|
|
@@ -40,8 +40,13 @@ def r_delim():
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
def r_subject():
|
|
43
|
-
"""Regex str for subject line
|
|
44
|
-
return r"
|
|
43
|
+
"""Regex str for subject line."""
|
|
44
|
+
return r" .+$"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def r_body():
|
|
48
|
+
"""Regex str for the body"""
|
|
49
|
+
return r"(?P<multi>\r?\n(?P<sep>^$\r?\n)?.+)?"
|
|
45
50
|
|
|
46
51
|
|
|
47
52
|
def r_autosquash_prefixes():
|
|
@@ -49,6 +54,15 @@ def r_autosquash_prefixes():
|
|
|
49
54
|
return "|".join(AUTOSQUASH_PREFIXES)
|
|
50
55
|
|
|
51
56
|
|
|
57
|
+
def r_comment():
|
|
58
|
+
"""Regex str for comment"""
|
|
59
|
+
return r"^#.*\r?\n?"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def strip_comments(input):
|
|
63
|
+
return re.sub(r_comment(), "", input, flags=re.MULTILINE)
|
|
64
|
+
|
|
65
|
+
|
|
52
66
|
def conventional_types(types=[]):
|
|
53
67
|
"""Return a list of Conventional Commits types merged with the given types."""
|
|
54
68
|
if set(types) & set(CONVENTIONAL_TYPES) == set():
|
|
@@ -63,11 +77,17 @@ def is_conventional(input, types=DEFAULT_TYPES, optional_scope=True):
|
|
|
63
77
|
|
|
64
78
|
Optionally provide a list of additional custom types.
|
|
65
79
|
"""
|
|
80
|
+
input = strip_comments(input)
|
|
66
81
|
types = conventional_types(types)
|
|
67
|
-
pattern = f"^({r_types(types)}){r_scope(optional_scope)}{r_delim()}{r_subject()}
|
|
68
|
-
regex = re.compile(pattern, re.
|
|
82
|
+
pattern = f"^({r_types(types)}){r_scope(optional_scope)}{r_delim()}{r_subject()}{r_body()}"
|
|
83
|
+
regex = re.compile(pattern, re.MULTILINE)
|
|
69
84
|
|
|
70
|
-
|
|
85
|
+
result = regex.match(input)
|
|
86
|
+
is_valid = bool(result)
|
|
87
|
+
if is_valid and result.group("multi") and not result.group("sep"):
|
|
88
|
+
is_valid = False
|
|
89
|
+
|
|
90
|
+
return is_valid
|
|
71
91
|
|
|
72
92
|
|
|
73
93
|
def has_autosquash_prefix(input):
|
{conventional_pre_commit-2.4.0 → conventional_pre_commit-3.1.0}/conventional_pre_commit/hook.py
RENAMED
|
@@ -24,7 +24,9 @@ def main(argv=[]):
|
|
|
24
24
|
"--force-scope", action="store_false", default=True, dest="optional_scope", help="Force commit to have scope defined."
|
|
25
25
|
)
|
|
26
26
|
parser.add_argument(
|
|
27
|
-
"--strict",
|
|
27
|
+
"--strict",
|
|
28
|
+
action="store_true",
|
|
29
|
+
help="Force commit to strictly follow Conventional Commits formatting. Disallows fixup! style commits.",
|
|
28
30
|
)
|
|
29
31
|
|
|
30
32
|
if len(argv) < 1:
|
|
@@ -64,7 +66,7 @@ See {Colors.LBLUE}https://git-scm.com/docs/git-commit/#_discussion{Colors.RESTOR
|
|
|
64
66
|
{Colors.LBLUE}https://www.conventionalcommits.org/{Colors.YELLOW}
|
|
65
67
|
|
|
66
68
|
Conventional Commits start with one of the below types, followed by a colon,
|
|
67
|
-
followed by the commit
|
|
69
|
+
followed by the commit subject and an optional body seperated by a blank line:{Colors.RESTORE}
|
|
68
70
|
|
|
69
71
|
{" ".join(format.conventional_types(args.types))}
|
|
70
72
|
|
|
@@ -78,7 +80,14 @@ See {Colors.LBLUE}https://git-scm.com/docs/git-commit/#_discussion{Colors.RESTOR
|
|
|
78
80
|
|
|
79
81
|
{Colors.YELLOW}Example commit with scope in parentheses after the type for more context:{Colors.RESTORE}
|
|
80
82
|
|
|
81
|
-
fix(account): remove infinite loop
|
|
83
|
+
fix(account): remove infinite loop
|
|
84
|
+
|
|
85
|
+
{Colors.YELLOW}Example commit with a body:{Colors.RESTORE}
|
|
86
|
+
|
|
87
|
+
fix: remove infinite loop
|
|
88
|
+
|
|
89
|
+
Additional information on the issue caused by the infinite loop
|
|
90
|
+
"""
|
|
82
91
|
)
|
|
83
92
|
return RESULT_FAIL
|
|
84
93
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version:
|
|
2
|
+
Name: conventional_pre_commit
|
|
3
|
+
Version: 3.1.0
|
|
4
4
|
Summary: A pre-commit hook that checks commit messages for Conventional Commits formatting.
|
|
5
5
|
Author-email: Compiler LLC <dev@compiler.la>
|
|
6
6
|
License: Apache License
|
|
@@ -209,16 +209,25 @@ Project-URL: code, https://github.com/compilerla/conventional-pre-commit
|
|
|
209
209
|
Project-URL: tracker, https://github.com/compilerla/conventional-pre-commit/issues
|
|
210
210
|
Keywords: git,pre-commit,conventional-commits
|
|
211
211
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
212
|
-
Requires-Python: >=3.
|
|
212
|
+
Requires-Python: >=3.8
|
|
213
213
|
Description-Content-Type: text/markdown
|
|
214
|
-
Provides-Extra: dev
|
|
215
214
|
License-File: LICENSE
|
|
215
|
+
Provides-Extra: dev
|
|
216
|
+
Requires-Dist: black; extra == "dev"
|
|
217
|
+
Requires-Dist: build; extra == "dev"
|
|
218
|
+
Requires-Dist: coverage; extra == "dev"
|
|
219
|
+
Requires-Dist: flake8; extra == "dev"
|
|
220
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
221
|
+
Requires-Dist: pytest; extra == "dev"
|
|
222
|
+
Requires-Dist: setuptools_scm; extra == "dev"
|
|
216
223
|
|
|
217
224
|
# conventional-pre-commit
|
|
218
225
|
|
|
219
226
|
A [`pre-commit`](https://pre-commit.com) hook to check commit messages for
|
|
220
227
|
[Conventional Commits](https://conventionalcommits.org) formatting.
|
|
221
228
|
|
|
229
|
+
Works with Python >= 3.8.
|
|
230
|
+
|
|
222
231
|
## Usage
|
|
223
232
|
|
|
224
233
|
Make sure `pre-commit` is [installed](https://pre-commit.com#install).
|
|
@@ -240,7 +249,7 @@ repos:
|
|
|
240
249
|
hooks:
|
|
241
250
|
- id: conventional-pre-commit
|
|
242
251
|
stages: [commit-msg]
|
|
243
|
-
args: []
|
|
252
|
+
args: []
|
|
244
253
|
```
|
|
245
254
|
|
|
246
255
|
Install the `pre-commit` script:
|
|
@@ -278,9 +287,15 @@ Example commit message fixing an issue:
|
|
|
278
287
|
|
|
279
288
|
fix: remove infinite loop
|
|
280
289
|
|
|
281
|
-
|
|
290
|
+
Example commit with scope in parentheses after the type for more context:
|
|
282
291
|
|
|
283
292
|
fix(account): remove infinite loop
|
|
293
|
+
|
|
294
|
+
Example commit with a body:
|
|
295
|
+
|
|
296
|
+
fix: remove infinite loop
|
|
297
|
+
|
|
298
|
+
Additional information on the issue caused by the infinite loop
|
|
284
299
|
```
|
|
285
300
|
|
|
286
301
|
Make a (conventional) commit :heavy_check_mark::
|
|
@@ -331,6 +346,40 @@ print(is_conventional("nope: this is not a conventional commit"))
|
|
|
331
346
|
print(is_conventional("custom: this is a conventional commit", types=["custom"]))
|
|
332
347
|
```
|
|
333
348
|
|
|
349
|
+
## Passing `args`
|
|
350
|
+
|
|
351
|
+
`conventional-pre-commit` supports a number of arguments to configure behavior:
|
|
352
|
+
|
|
353
|
+
```shell
|
|
354
|
+
$ conventional-pre-commit -h
|
|
355
|
+
usage: conventional-pre-commit [-h] [--force-scope] [--strict] [types ...] input
|
|
356
|
+
|
|
357
|
+
Check a git commit message for Conventional Commits formatting.
|
|
358
|
+
|
|
359
|
+
positional arguments:
|
|
360
|
+
types Optional list of types to support
|
|
361
|
+
input A file containing a git commit message
|
|
362
|
+
|
|
363
|
+
options:
|
|
364
|
+
-h, --help show this help message and exit
|
|
365
|
+
--force-scope Force commit to have scope defined.
|
|
366
|
+
--strict Force commit to strictly follow Conventional Commits formatting. Disallows fixup! style commits.
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
Supply arguments on the command-line, or via the pre-commit `hooks.args` property:
|
|
370
|
+
|
|
371
|
+
```yaml
|
|
372
|
+
repos:
|
|
373
|
+
- repo: https://github.com/compilerla/conventional-pre-commit
|
|
374
|
+
rev: <git sha or tag>
|
|
375
|
+
hooks:
|
|
376
|
+
- id: conventional-pre-commit
|
|
377
|
+
stages: [commit-msg]
|
|
378
|
+
args: [--strict, --force-scope, feat, fix, chore, test, custom]
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**NOTE:** when using as a pre-commit hook, `input` is supplied automatically (with the current commit's message).
|
|
382
|
+
|
|
334
383
|
## Development
|
|
335
384
|
|
|
336
385
|
`conventional-pre-commit` comes with a [VS Code devcontainer](https://code.visualstudio.com/learn/develop-cloud/containers)
|
|
@@ -354,22 +403,11 @@ Versioning generally follows [Semantic Versioning](https://semver.org/).
|
|
|
354
403
|
|
|
355
404
|
## Making a release
|
|
356
405
|
|
|
357
|
-
Releases to PyPI are triggered by
|
|
358
|
-
|
|
359
|
-
1. Create a branch `chore/release`
|
|
360
|
-
1. Bump the version in `pyproject.toml`
|
|
361
|
-
1. PR, merge `chore/release` into `main`
|
|
362
|
-
1. Tag `main` with the new version (prefixed by `v`):
|
|
363
|
-
|
|
364
|
-
```bash
|
|
365
|
-
git fetch
|
|
366
|
-
git reset --hard origin/main
|
|
367
|
-
git tag vX.Y.Z
|
|
368
|
-
git push origin vX.Y.Z
|
|
369
|
-
```
|
|
406
|
+
Releases to PyPI and GitHub are triggered by pushing a tag.
|
|
370
407
|
|
|
371
|
-
1.
|
|
372
|
-
1.
|
|
408
|
+
1. Ensure all changes for the release are present in the `main` branch
|
|
409
|
+
1. Tag with the new version: `git tag vX.Y.Z` for regular release, `git tag vX.Y.Z-preN` for pre-release
|
|
410
|
+
1. Push the new version tag: `git push origin vX.Y.Z`
|
|
373
411
|
|
|
374
412
|
## License
|
|
375
413
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.dockerignore
|
|
2
|
+
.flake8
|
|
3
|
+
.gitignore
|
|
4
|
+
.pre-commit-config.yaml
|
|
5
|
+
.pre-commit-hooks.yaml
|
|
6
|
+
LICENSE
|
|
7
|
+
README.md
|
|
8
|
+
pyproject.toml
|
|
9
|
+
.devcontainer/Dockerfile
|
|
10
|
+
.devcontainer/compose.yml
|
|
11
|
+
.devcontainer/devcontainer.json
|
|
12
|
+
.github/dependabot.yaml
|
|
13
|
+
.github/workflows/release.yml
|
|
14
|
+
.github/workflows/tests.yml
|
|
15
|
+
.vscode/settings.json
|
|
16
|
+
conventional_pre_commit/__init__.py
|
|
17
|
+
conventional_pre_commit/format.py
|
|
18
|
+
conventional_pre_commit/hook.py
|
|
19
|
+
conventional_pre_commit.egg-info/PKG-INFO
|
|
20
|
+
conventional_pre_commit.egg-info/SOURCES.txt
|
|
21
|
+
conventional_pre_commit.egg-info/dependency_links.txt
|
|
22
|
+
conventional_pre_commit.egg-info/entry_points.txt
|
|
23
|
+
conventional_pre_commit.egg-info/requires.txt
|
|
24
|
+
conventional_pre_commit.egg-info/top_level.txt
|
|
25
|
+
tests/__init__.py
|
|
26
|
+
tests/conftest.py
|
|
27
|
+
tests/run.sh
|
|
28
|
+
tests/test_format.py
|
|
29
|
+
tests/test_hook.py
|
|
30
|
+
tests/messages/bad_commit
|
|
31
|
+
tests/messages/conventional_commit
|
|
32
|
+
tests/messages/conventional_commit_bad_multi_line
|
|
33
|
+
tests/messages/conventional_commit_gbk
|
|
34
|
+
tests/messages/conventional_commit_multi_line
|
|
35
|
+
tests/messages/conventional_commit_utf-8
|
|
36
|
+
tests/messages/conventional_commit_with_scope
|
|
37
|
+
tests/messages/custom_commit
|
|
38
|
+
tests/messages/fixup_commit
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "conventional_pre_commit"
|
|
3
|
-
|
|
3
|
+
dynamic = ["version"]
|
|
4
4
|
description = "A pre-commit hook that checks commit messages for Conventional Commits formatting."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { file = "LICENSE" }
|
|
@@ -9,7 +9,7 @@ keywords = ["git", "pre-commit", "conventional-commits"]
|
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Compiler LLC", email = "dev@compiler.la" }
|
|
11
11
|
]
|
|
12
|
-
requires-python = ">=3.
|
|
12
|
+
requires-python = ">=3.8"
|
|
13
13
|
dependencies = []
|
|
14
14
|
|
|
15
15
|
[project.urls]
|
|
@@ -20,17 +20,18 @@ tracker = "https://github.com/compilerla/conventional-pre-commit/issues"
|
|
|
20
20
|
dev = [
|
|
21
21
|
"black",
|
|
22
22
|
"build",
|
|
23
|
+
"coverage",
|
|
23
24
|
"flake8",
|
|
24
25
|
"pre-commit",
|
|
25
26
|
"pytest",
|
|
26
|
-
"
|
|
27
|
+
"setuptools_scm",
|
|
27
28
|
]
|
|
28
29
|
|
|
29
30
|
[project.scripts]
|
|
30
31
|
conventional-pre-commit = "conventional_pre_commit.hook:main"
|
|
31
32
|
|
|
32
33
|
[build-system]
|
|
33
|
-
requires = ["setuptools>=
|
|
34
|
+
requires = ["setuptools>=65", "setuptools-scm>=8"]
|
|
34
35
|
build-backend = "setuptools.build_meta"
|
|
35
36
|
|
|
36
37
|
[tool.black]
|
|
@@ -38,6 +39,14 @@ line-length = 127
|
|
|
38
39
|
target-version = ['py311']
|
|
39
40
|
include = '\.pyi?$'
|
|
40
41
|
|
|
42
|
+
[tool.coverage.run]
|
|
43
|
+
branch = true
|
|
44
|
+
relative_files = true
|
|
45
|
+
source = ["conventional_pre_commit"]
|
|
46
|
+
|
|
47
|
+
[tool.pyright]
|
|
48
|
+
include = ["conventional_pre_commit", "tests"]
|
|
49
|
+
|
|
41
50
|
[tool.pytest.ini_options]
|
|
42
51
|
testpaths = ["tests"]
|
|
43
52
|
norecursedirs = [
|
|
@@ -46,3 +55,9 @@ norecursedirs = [
|
|
|
46
55
|
".pytest_cache",
|
|
47
56
|
".vscode",
|
|
48
57
|
]
|
|
58
|
+
|
|
59
|
+
[tool.setuptools]
|
|
60
|
+
packages = ["conventional_pre_commit"]
|
|
61
|
+
|
|
62
|
+
[tool.setuptools_scm]
|
|
63
|
+
# intentionally left blank, but we need the section header to activate the tool
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import os.path
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
TEST_DIR = os.path.abspath(os.path.dirname(__file__))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def get_message_path(path):
|
|
9
|
+
return os.path.join(TEST_DIR, "messages", path)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.fixture
|
|
13
|
+
def bad_commit_path():
|
|
14
|
+
return get_message_path("bad_commit")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture
|
|
18
|
+
def conventional_commit_path():
|
|
19
|
+
return get_message_path("conventional_commit")
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.fixture
|
|
23
|
+
def conventional_commit_with_scope_path():
|
|
24
|
+
return get_message_path("conventional_commit_with_scope")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@pytest.fixture
|
|
28
|
+
def custom_commit_path():
|
|
29
|
+
return get_message_path("custom_commit")
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@pytest.fixture
|
|
33
|
+
def conventional_utf8_commit_path():
|
|
34
|
+
return get_message_path("conventional_commit_utf-8")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@pytest.fixture
|
|
38
|
+
def conventional_gbk_commit_path():
|
|
39
|
+
return get_message_path("conventional_commit_gbk")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@pytest.fixture
|
|
43
|
+
def fixup_commit_path():
|
|
44
|
+
return get_message_path("fixup_commit")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@pytest.fixture
|
|
48
|
+
def conventional_commit_bad_multi_line_path():
|
|
49
|
+
return get_message_path("conventional_commit_bad_multi_line")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@pytest.fixture
|
|
53
|
+
def conventional_commit_multi_line_path():
|
|
54
|
+
return get_message_path("conventional_commit_multi_line")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bad: message
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
feat: message
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
feat: utf-8 test ����
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
feat: utf-8 test 测试
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
feat(scope): message
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
custom: message
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fixup! feature: implement something cool
|
|
@@ -61,6 +61,7 @@ def test_r_scope__special_chars():
|
|
|
61
61
|
assert regex.match("(some/thing)")
|
|
62
62
|
assert regex.match("(some thing)")
|
|
63
63
|
assert regex.match("(some:thing)")
|
|
64
|
+
assert regex.match("(some,thing)")
|
|
64
65
|
|
|
65
66
|
|
|
66
67
|
def test_r_delim():
|
|
@@ -122,6 +123,34 @@ def test_conventional_types__custom():
|
|
|
122
123
|
assert set(["custom", *format.CONVENTIONAL_TYPES]) == set(result)
|
|
123
124
|
|
|
124
125
|
|
|
126
|
+
def test_r_comment_single():
|
|
127
|
+
regex = re.compile(format.r_comment())
|
|
128
|
+
assert regex.match("# Some comment")
|
|
129
|
+
assert not regex.match("Some comment")
|
|
130
|
+
assert not regex.match(" # Some comment")
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def test_strip_comments__consecutive():
|
|
134
|
+
input = """feat(scope): message
|
|
135
|
+
# Please enter the commit message for your changes.
|
|
136
|
+
# These are comments usually added by editors, f.ex. with export EDITOR=vim
|
|
137
|
+
"""
|
|
138
|
+
result = format.strip_comments(input)
|
|
139
|
+
assert result.count("\n") == 1
|
|
140
|
+
assert result.strip() == "feat(scope): message"
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def test_strip_comments__spaced():
|
|
144
|
+
input = """feat(scope): message
|
|
145
|
+
# Please enter the commit message for your changes.
|
|
146
|
+
|
|
147
|
+
# These are comments usually added by editors, f.ex. with export EDITOR=vim
|
|
148
|
+
"""
|
|
149
|
+
result = format.strip_comments(input)
|
|
150
|
+
assert result.count("\n") == 2
|
|
151
|
+
assert result.strip() == "feat(scope): message"
|
|
152
|
+
|
|
153
|
+
|
|
125
154
|
@pytest.mark.parametrize("type", format.DEFAULT_TYPES)
|
|
126
155
|
def test_is_conventional__default_type(type):
|
|
127
156
|
input = f"{type}: message"
|
|
@@ -162,6 +191,23 @@ def test_is_conventional__with_scope():
|
|
|
162
191
|
assert format.is_conventional(input)
|
|
163
192
|
|
|
164
193
|
|
|
194
|
+
def test_is_conventional__body_multiline_body_bad_type():
|
|
195
|
+
input = """wrong: message
|
|
196
|
+
|
|
197
|
+
more_message
|
|
198
|
+
"""
|
|
199
|
+
|
|
200
|
+
assert not format.is_conventional(input)
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def test_is_conventional__bad_body_multiline():
|
|
204
|
+
input = """feat(scope): message
|
|
205
|
+
more message
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
assert not format.is_conventional(input)
|
|
209
|
+
|
|
210
|
+
|
|
165
211
|
def test_is_conventional__body_multiline():
|
|
166
212
|
input = """feat(scope): message
|
|
167
213
|
|
|
@@ -171,6 +217,24 @@ def test_is_conventional__body_multiline():
|
|
|
171
217
|
assert format.is_conventional(input)
|
|
172
218
|
|
|
173
219
|
|
|
220
|
+
def test_is_conventional__bad_body_multiline_paragraphs():
|
|
221
|
+
input = """feat(scope): message
|
|
222
|
+
more message
|
|
223
|
+
|
|
224
|
+
more body message
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
assert not format.is_conventional(input)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def test_is_conventional__comment():
|
|
231
|
+
input = """feat(scope): message
|
|
232
|
+
# Please enter the commit message for your changes.
|
|
233
|
+
# These are comments usually added by editors, f.ex. with export EDITOR=vim
|
|
234
|
+
"""
|
|
235
|
+
assert format.is_conventional(input)
|
|
236
|
+
|
|
237
|
+
|
|
174
238
|
@pytest.mark.parametrize("char", ['"', "'", "`", "#", "&"])
|
|
175
239
|
def test_is_conventional__body_special_char(char):
|
|
176
240
|
input = f"feat: message with {char}"
|
|
@@ -2,7 +2,7 @@ import subprocess
|
|
|
2
2
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
5
|
-
from conventional_pre_commit.hook import
|
|
5
|
+
from conventional_pre_commit.hook import RESULT_FAIL, RESULT_SUCCESS, main
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
@pytest.fixture
|
|
@@ -46,6 +46,54 @@ def test_main_success__custom_conventional(conventional_commit_path):
|
|
|
46
46
|
assert result == RESULT_SUCCESS
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
def test_main_success__conventional_utf8(conventional_utf8_commit_path):
|
|
50
|
+
result = main([conventional_utf8_commit_path])
|
|
51
|
+
|
|
52
|
+
assert result == RESULT_SUCCESS
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_main_fail__conventional_gbk(conventional_gbk_commit_path):
|
|
56
|
+
result = main([conventional_gbk_commit_path])
|
|
57
|
+
|
|
58
|
+
assert result == RESULT_FAIL
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_main_fail__conventional_with_scope(conventional_commit_path):
|
|
62
|
+
result = main(["--force-scope", conventional_commit_path])
|
|
63
|
+
|
|
64
|
+
assert result == RESULT_FAIL
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_main_success__conventional_with_scope(cmd, conventional_commit_with_scope_path):
|
|
68
|
+
result = main(["--force-scope", conventional_commit_with_scope_path])
|
|
69
|
+
|
|
70
|
+
assert result == RESULT_SUCCESS
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_main_success__fixup_commit(fixup_commit_path):
|
|
74
|
+
result = main([fixup_commit_path])
|
|
75
|
+
|
|
76
|
+
assert result == RESULT_SUCCESS
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_main_fail__fixup_commit(fixup_commit_path):
|
|
80
|
+
result = main(["--strict", fixup_commit_path])
|
|
81
|
+
|
|
82
|
+
assert result == RESULT_FAIL
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_main_success__conventional_commit_multi_line(conventional_commit_multi_line_path):
|
|
86
|
+
result = main([conventional_commit_multi_line_path])
|
|
87
|
+
|
|
88
|
+
assert result == RESULT_SUCCESS
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_main_fail__conventional_commit_bad_multi_line(conventional_commit_bad_multi_line_path):
|
|
92
|
+
result = main([conventional_commit_bad_multi_line_path])
|
|
93
|
+
|
|
94
|
+
assert result == RESULT_FAIL
|
|
95
|
+
|
|
96
|
+
|
|
49
97
|
def test_subprocess_fail__missing_args(cmd):
|
|
50
98
|
result = subprocess.call(cmd)
|
|
51
99
|
|
|
@@ -82,37 +130,37 @@ def test_subprocess_success__custom_conventional(cmd, conventional_commit_path):
|
|
|
82
130
|
assert result == RESULT_SUCCESS
|
|
83
131
|
|
|
84
132
|
|
|
85
|
-
def
|
|
86
|
-
result = main([conventional_utf8_commit_path])
|
|
87
|
-
|
|
88
|
-
assert result == RESULT_SUCCESS
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def test_main_fail__conventional_gbk(conventional_gbk_commit_path):
|
|
92
|
-
result = main([conventional_gbk_commit_path])
|
|
93
|
-
|
|
94
|
-
assert result == RESULT_FAIL
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def test_main_fail__conventional_with_scope(cmd, conventional_commit_path):
|
|
133
|
+
def test_subprocess_fail__conventional_with_scope(cmd, conventional_commit_path):
|
|
98
134
|
result = subprocess.call((cmd, "--force-scope", conventional_commit_path))
|
|
99
135
|
|
|
100
136
|
assert result == RESULT_FAIL
|
|
101
137
|
|
|
102
138
|
|
|
103
|
-
def
|
|
139
|
+
def test_subprocess_success__conventional_with_scope(cmd, conventional_commit_with_scope_path):
|
|
104
140
|
result = subprocess.call((cmd, "--force-scope", conventional_commit_with_scope_path))
|
|
105
141
|
|
|
106
142
|
assert result == RESULT_SUCCESS
|
|
107
143
|
|
|
108
144
|
|
|
109
|
-
def
|
|
145
|
+
def test_subprocess_success__fixup_commit(cmd, fixup_commit_path):
|
|
110
146
|
result = subprocess.call((cmd, fixup_commit_path))
|
|
111
147
|
|
|
112
148
|
assert result == RESULT_SUCCESS
|
|
113
149
|
|
|
114
150
|
|
|
115
|
-
def
|
|
151
|
+
def test_subprocess_fail__fixup_commit(cmd, fixup_commit_path):
|
|
116
152
|
result = subprocess.call((cmd, "--strict", fixup_commit_path))
|
|
117
153
|
|
|
118
154
|
assert result == RESULT_FAIL
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def test_subprocess_success__conventional_commit_multi_line(cmd, conventional_commit_multi_line_path):
|
|
158
|
+
result = subprocess.call((cmd, conventional_commit_multi_line_path))
|
|
159
|
+
|
|
160
|
+
assert result == RESULT_SUCCESS
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def test_subprocess_fail__conventional_commit_bad_multi_line(cmd, conventional_commit_bad_multi_line_path):
|
|
164
|
+
result = subprocess.call((cmd, conventional_commit_bad_multi_line_path))
|
|
165
|
+
|
|
166
|
+
assert result == RESULT_FAIL
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
pyproject.toml
|
|
4
|
-
conventional_pre_commit/__init__.py
|
|
5
|
-
conventional_pre_commit/format.py
|
|
6
|
-
conventional_pre_commit/hook.py
|
|
7
|
-
conventional_pre_commit.egg-info/PKG-INFO
|
|
8
|
-
conventional_pre_commit.egg-info/SOURCES.txt
|
|
9
|
-
conventional_pre_commit.egg-info/dependency_links.txt
|
|
10
|
-
conventional_pre_commit.egg-info/entry_points.txt
|
|
11
|
-
conventional_pre_commit.egg-info/requires.txt
|
|
12
|
-
conventional_pre_commit.egg-info/top_level.txt
|
|
13
|
-
tests/test_format.py
|
|
14
|
-
tests/test_hook.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|