conventional-pre-commit 3.0.0__tar.gz → 3.2.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.0.0 → conventional_pre_commit-3.2.0}/.github/workflows/release.yml +2 -2
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.github/workflows/tests.yml +2 -2
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.pre-commit-config.yaml +4 -4
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/PKG-INFO +1 -1
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit/format.py +22 -2
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit.egg-info/PKG-INFO +2 -2
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/test_format.py +104 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.devcontainer/Dockerfile +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.devcontainer/compose.yml +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.devcontainer/devcontainer.json +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.dockerignore +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.flake8 +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.github/dependabot.yaml +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.gitignore +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.pre-commit-hooks.yaml +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.vscode/settings.json +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/LICENSE +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/README.md +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit/__init__.py +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit/hook.py +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit.egg-info/SOURCES.txt +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit.egg-info/dependency_links.txt +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit.egg-info/entry_points.txt +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit.egg-info/requires.txt +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit.egg-info/top_level.txt +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/pyproject.toml +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/setup.cfg +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/__init__.py +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/conftest.py +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/bad_commit +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/conventional_commit +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/conventional_commit_bad_multi_line +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/conventional_commit_gbk +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/conventional_commit_multi_line +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/conventional_commit_utf-8 +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/conventional_commit_with_scope +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/custom_commit +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/fixup_commit +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/run.sh +0 -0
- {conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/test_hook.py +0 -0
{conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.github/workflows/release.yml
RENAMED
|
@@ -24,7 +24,7 @@ jobs:
|
|
|
24
24
|
steps:
|
|
25
25
|
- uses: actions/checkout@v4
|
|
26
26
|
|
|
27
|
-
- uses: actions/setup-python@
|
|
27
|
+
- uses: actions/setup-python@v5
|
|
28
28
|
with:
|
|
29
29
|
python-version: "3.11"
|
|
30
30
|
cache: pip
|
|
@@ -38,7 +38,7 @@ jobs:
|
|
|
38
38
|
|
|
39
39
|
- name: Release
|
|
40
40
|
id: release
|
|
41
|
-
uses: softprops/action-gh-release@
|
|
41
|
+
uses: softprops/action-gh-release@v2
|
|
42
42
|
with:
|
|
43
43
|
files: |
|
|
44
44
|
./dist/*.whl
|
|
@@ -28,7 +28,7 @@ jobs:
|
|
|
28
28
|
- uses: actions/checkout@v4
|
|
29
29
|
|
|
30
30
|
- name: Set up Python ${{ matrix.python-version }}
|
|
31
|
-
uses: actions/setup-python@
|
|
31
|
+
uses: actions/setup-python@v5
|
|
32
32
|
with:
|
|
33
33
|
python-version: ${{ matrix.python-version }}
|
|
34
34
|
cache: pip
|
|
@@ -44,7 +44,7 @@ jobs:
|
|
|
44
44
|
|
|
45
45
|
- name: Coverage comment
|
|
46
46
|
uses: py-cov-action/python-coverage-comment-action@v3
|
|
47
|
-
if: github.event_name != 'workflow_call' && matrix.version == '3.11'
|
|
47
|
+
if: github.event_name != 'workflow_call' && matrix.python-version == '3.11'
|
|
48
48
|
with:
|
|
49
49
|
GITHUB_TOKEN: ${{ github.token }}
|
|
50
50
|
MINIMUM_GREEN: 90
|
|
@@ -18,28 +18,28 @@ repos:
|
|
|
18
18
|
- id: check-added-large-files
|
|
19
19
|
|
|
20
20
|
- repo: https://github.com/psf/black
|
|
21
|
-
rev:
|
|
21
|
+
rev: 24.3.0
|
|
22
22
|
hooks:
|
|
23
23
|
- id: black
|
|
24
24
|
types:
|
|
25
25
|
- python
|
|
26
26
|
|
|
27
27
|
- repo: https://github.com/PyCQA/flake8
|
|
28
|
-
rev:
|
|
28
|
+
rev: 7.0.0
|
|
29
29
|
hooks:
|
|
30
30
|
- id: flake8
|
|
31
31
|
types:
|
|
32
32
|
- python
|
|
33
33
|
|
|
34
34
|
- repo: https://github.com/pycqa/bandit
|
|
35
|
-
rev: 1.7.
|
|
35
|
+
rev: 1.7.8
|
|
36
36
|
hooks:
|
|
37
37
|
- id: bandit
|
|
38
38
|
args: ["-ll"]
|
|
39
39
|
files: .py$
|
|
40
40
|
|
|
41
41
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
42
|
-
rev:
|
|
42
|
+
rev: v4.0.0-alpha.8
|
|
43
43
|
hooks:
|
|
44
44
|
- id: prettier
|
|
45
45
|
types_or: [javascript]
|
{conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.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():
|
|
@@ -54,6 +54,24 @@ def r_autosquash_prefixes():
|
|
|
54
54
|
return "|".join(AUTOSQUASH_PREFIXES)
|
|
55
55
|
|
|
56
56
|
|
|
57
|
+
def r_verbose_diff():
|
|
58
|
+
"""Regex str for verbose diff"""
|
|
59
|
+
return r"(?P<diff>(^# -* >8 -*$\r?\n)(^# .*$\r?\n)+(diff ){1}(.*\r?\n)*)"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def strip_verbose_diff(input):
|
|
63
|
+
return re.sub(r_verbose_diff(), "", input, flags=re.MULTILINE)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def r_comment():
|
|
67
|
+
"""Regex str for comment"""
|
|
68
|
+
return r"^#.*\r?\n?"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def strip_comments(input):
|
|
72
|
+
return re.sub(r_comment(), "", input, flags=re.MULTILINE)
|
|
73
|
+
|
|
74
|
+
|
|
57
75
|
def conventional_types(types=[]):
|
|
58
76
|
"""Return a list of Conventional Commits types merged with the given types."""
|
|
59
77
|
if set(types) & set(CONVENTIONAL_TYPES) == set():
|
|
@@ -68,6 +86,8 @@ def is_conventional(input, types=DEFAULT_TYPES, optional_scope=True):
|
|
|
68
86
|
|
|
69
87
|
Optionally provide a list of additional custom types.
|
|
70
88
|
"""
|
|
89
|
+
input = strip_verbose_diff(input)
|
|
90
|
+
input = strip_comments(input)
|
|
71
91
|
types = conventional_types(types)
|
|
72
92
|
pattern = f"^({r_types(types)}){r_scope(optional_scope)}{r_delim()}{r_subject()}{r_body()}"
|
|
73
93
|
regex = re.compile(pattern, re.MULTILINE)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
|
-
Name:
|
|
3
|
-
Version: 3.
|
|
2
|
+
Name: conventional_pre_commit
|
|
3
|
+
Version: 3.2.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
|
|
@@ -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,101 @@ 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
|
+
|
|
154
|
+
def test_r_verbose_diff__has_diff():
|
|
155
|
+
regex = re.compile(format.r_verbose_diff(), re.MULTILINE)
|
|
156
|
+
input = """# ----------- >8 -----------
|
|
157
|
+
# Some comment
|
|
158
|
+
# Some comment
|
|
159
|
+
diff --git a/file b/file
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
assert regex.match(input)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_r_verbose_diff__no_diff():
|
|
166
|
+
regex = re.compile(format.r_verbose_diff(), re.MULTILINE)
|
|
167
|
+
input = """# ----------- >8 -----------
|
|
168
|
+
# Some comment
|
|
169
|
+
# Some comment
|
|
170
|
+
"""
|
|
171
|
+
|
|
172
|
+
assert not regex.match(input)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def test_r_verbose_diff__no_extra_comments():
|
|
176
|
+
regex = re.compile(format.r_verbose_diff(), re.MULTILINE)
|
|
177
|
+
input = """# ----------- >8 -----------
|
|
178
|
+
diff --git a/file b/file
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
assert not regex.match(input)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def test_strip_verbose_diff__has_diff():
|
|
185
|
+
input = """feat(scope): message
|
|
186
|
+
# Please enter the commit message for your changes.
|
|
187
|
+
|
|
188
|
+
# These are comments usually added by editors, f.ex. with export EDITOR=vim
|
|
189
|
+
# ----------- >8 -----------
|
|
190
|
+
# Some comment
|
|
191
|
+
# Some comment
|
|
192
|
+
diff --git a/file b/file
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
result = format.strip_verbose_diff(input)
|
|
196
|
+
assert result.count("\n") == 4
|
|
197
|
+
assert (
|
|
198
|
+
result
|
|
199
|
+
== """feat(scope): message
|
|
200
|
+
# Please enter the commit message for your changes.
|
|
201
|
+
|
|
202
|
+
# These are comments usually added by editors, f.ex. with export EDITOR=vim
|
|
203
|
+
"""
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def test_strip_verbose_diff__no_diff():
|
|
208
|
+
input = """feat(scope): message
|
|
209
|
+
# Please enter the commit message for your changes.
|
|
210
|
+
|
|
211
|
+
# These are comments usually added by editors, f.ex. with export EDITOR=vim
|
|
212
|
+
# ----------- >8 -----------
|
|
213
|
+
# Some comment
|
|
214
|
+
# Some comment
|
|
215
|
+
"""
|
|
216
|
+
|
|
217
|
+
result = format.strip_verbose_diff(input)
|
|
218
|
+
assert result == input
|
|
219
|
+
|
|
220
|
+
|
|
125
221
|
@pytest.mark.parametrize("type", format.DEFAULT_TYPES)
|
|
126
222
|
def test_is_conventional__default_type(type):
|
|
127
223
|
input = f"{type}: message"
|
|
@@ -198,6 +294,14 @@ def test_is_conventional__bad_body_multiline_paragraphs():
|
|
|
198
294
|
assert not format.is_conventional(input)
|
|
199
295
|
|
|
200
296
|
|
|
297
|
+
def test_is_conventional__comment():
|
|
298
|
+
input = """feat(scope): message
|
|
299
|
+
# Please enter the commit message for your changes.
|
|
300
|
+
# These are comments usually added by editors, f.ex. with export EDITOR=vim
|
|
301
|
+
"""
|
|
302
|
+
assert format.is_conventional(input)
|
|
303
|
+
|
|
304
|
+
|
|
201
305
|
@pytest.mark.parametrize("char", ['"', "'", "`", "#", "&"])
|
|
202
306
|
def test_is_conventional__body_special_char(char):
|
|
203
307
|
input = f"feat: message with {char}"
|
|
File without changes
|
|
File without changes
|
{conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/.devcontainer/devcontainer.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit/__init__.py
RENAMED
|
File without changes
|
{conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/conventional_pre_commit/hook.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/conventional_commit
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{conventional_pre_commit-3.0.0 → conventional_pre_commit-3.2.0}/tests/messages/custom_commit
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|