ansys-pre-commit-hooks 0.3.1__tar.gz → 0.4.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.
- ansys_pre_commit_hooks-0.3.1/README.rst → ansys_pre_commit_hooks-0.4.0/PKG-INFO +95 -5
- ansys_pre_commit_hooks-0.3.1/PKG-INFO → ansys_pre_commit_hooks-0.4.0/README.rst +58 -38
- {ansys_pre_commit_hooks-0.3.1 → ansys_pre_commit_hooks-0.4.0}/pyproject.toml +19 -9
- {ansys_pre_commit_hooks-0.3.1 → ansys_pre_commit_hooks-0.4.0}/src/ansys/pre_commit_hooks/add_license_headers.py +92 -9
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/tech_review.py +737 -0
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/templates/AUTHORS +12 -0
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/templates/CODE_OF_CONDUCT.md +65 -0
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/templates/CONTRIBUTING.md +12 -0
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/templates/CONTRIBUTORS.md +9 -0
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/templates/LICENSE +21 -0
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/templates/README.md +81 -0
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/templates/README.rst +107 -0
- ansys_pre_commit_hooks-0.4.0/src/ansys/pre_commit_hooks/templates/dependabot.yml +16 -0
- {ansys_pre_commit_hooks-0.3.1 → ansys_pre_commit_hooks-0.4.0}/LICENSE +0 -0
- {ansys_pre_commit_hooks-0.3.1 → ansys_pre_commit_hooks-0.4.0}/src/ansys/pre_commit_hooks/__init__.py +0 -0
- {ansys_pre_commit_hooks-0.3.1 → ansys_pre_commit_hooks-0.4.0}/src/ansys/pre_commit_hooks/assets/.reuse/templates/ansys.jinja2 +0 -0
- {ansys_pre_commit_hooks-0.3.1 → ansys_pre_commit_hooks-0.4.0}/src/ansys/pre_commit_hooks/assets/LICENSES/MIT.txt +0 -0
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ansys-pre-commit-hooks
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: A Python wrapper to create Ansys-tailored pre-commit hooks
|
|
5
|
+
Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
6
|
+
Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
7
|
+
Requires-Python: >=3.9,<4
|
|
8
|
+
Description-Content-Type: text/x-rst
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Dist: GitPython==3.1.43
|
|
17
|
+
Requires-Dist: importlib-metadata==8.0.0
|
|
18
|
+
Requires-Dist: Jinja2==3.1.4
|
|
19
|
+
Requires-Dist: reuse==3.0.2
|
|
20
|
+
Requires-Dist: requests==2.32.3
|
|
21
|
+
Requires-Dist: semver==3.0.2
|
|
22
|
+
Requires-Dist: toml==0.10.2
|
|
23
|
+
Requires-Dist: ansys-sphinx-theme[autoapi]==0.16.6 ; extra == "doc"
|
|
24
|
+
Requires-Dist: numpydoc==1.7.0 ; extra == "doc"
|
|
25
|
+
Requires-Dist: sphinx==7.3.7 ; extra == "doc"
|
|
26
|
+
Requires-Dist: sphinx-autodoc-typehints==2.2.2 ; extra == "doc"
|
|
27
|
+
Requires-Dist: sphinx-copybutton==0.5.1 ; extra == "doc"
|
|
28
|
+
Requires-Dist: pytest==8.2.2 ; extra == "tests"
|
|
29
|
+
Requires-Dist: pytest-cov==5.0.0 ; extra == "tests"
|
|
30
|
+
Project-URL: Documentation, https://pre-commit-hooks.docs.ansys.com
|
|
31
|
+
Project-URL: Homepage, https://github.com/ansys/pre-commit-hooks
|
|
32
|
+
Project-URL: Source, https://github.com/ansys/pre-commit-hooks
|
|
33
|
+
Project-URL: Tracker, https://github.com/ansys/pre-commit-hooks/issues
|
|
34
|
+
Provides-Extra: doc
|
|
35
|
+
Provides-Extra: tests
|
|
36
|
+
|
|
1
37
|
Ansys pre-commit hooks
|
|
2
38
|
======================
|
|
3
39
|
|pyansys| |python| |pypi| |GH-CI| |MIT| |black| |pre-commit-ci|
|
|
@@ -36,8 +72,8 @@ Currently, these hooks are available:
|
|
|
36
72
|
* ``add-license-headers``: Add missing license headers to files by using
|
|
37
73
|
`REUSE <https://reuse.software/>`_ . To use this hook, you must
|
|
38
74
|
have ``REUSE`` implemented in your repository.
|
|
39
|
-
|
|
40
|
-
|
|
75
|
+
* ``tech-review``: Do a technical review of your repository according to
|
|
76
|
+
`Ansys repository requirements <https://dev.docs.pyansys.com/packaging/structure.html>`_`
|
|
41
77
|
|
|
42
78
|
``add-license-headers`` setup
|
|
43
79
|
-----------------------------
|
|
@@ -84,7 +120,7 @@ Set custom arguments
|
|
|
84
120
|
.. code:: yaml
|
|
85
121
|
|
|
86
122
|
- repo: https://github.com/ansys/pre-commit-hooks
|
|
87
|
-
rev: v0.
|
|
123
|
+
rev: v0.4.0
|
|
88
124
|
hooks:
|
|
89
125
|
- id: add-license-headers
|
|
90
126
|
args: ["--custom_copyright", "custom copyright phrase", "--custom_template", "template_name", "--custom_license", "license_name", "--ignore_license_check", "--start_year", "2023"]
|
|
@@ -129,7 +165,7 @@ the hook should run on, add the necessary regex to the ``files`` line in your
|
|
|
129
165
|
.. code:: yaml
|
|
130
166
|
|
|
131
167
|
- repo: https://github.com/ansys/pre-commit-hooks
|
|
132
|
-
rev: v0.
|
|
168
|
+
rev: v0.4.0
|
|
133
169
|
hooks:
|
|
134
170
|
- id: add-license-headers
|
|
135
171
|
files: '(src|examples|tests|newFolder)/.*\.(py|newExtension)|\.(proto|newExtension)'
|
|
@@ -142,7 +178,7 @@ In .pre-commit-config.yaml:
|
|
|
142
178
|
.. code:: yaml
|
|
143
179
|
|
|
144
180
|
- repo: https://github.com/ansys/pre-commit-hooks
|
|
145
|
-
rev: v0.
|
|
181
|
+
rev: v0.4.0
|
|
146
182
|
hooks:
|
|
147
183
|
- id: add-license-headers
|
|
148
184
|
exclude: |
|
|
@@ -160,6 +196,59 @@ In .pre-commit-config.yaml:
|
|
|
160
196
|
* ``.*\.js`` excludes all .js files in all directories.
|
|
161
197
|
* ``\..*`` excludes all hidden files.
|
|
162
198
|
|
|
199
|
+
``tech-review`` setup
|
|
200
|
+
---------------------
|
|
201
|
+
|
|
202
|
+
These are the default values for the arguments of the tech-review hook:
|
|
203
|
+
|
|
204
|
+
* ``--author_maint_name=ANSYS, Inc.``
|
|
205
|
+
* ``--author_maint_email=pyansys.core@ansys.com``
|
|
206
|
+
* ``--license=MIT``
|
|
207
|
+
* ``--url=https://github.com/ansys/{repo-name}``, replacing ``repo-name`` with the name of the repository
|
|
208
|
+
|
|
209
|
+
The ``--author_maint_name`` is the name of the author and maintainer in the ``pyproject.toml`` file.
|
|
210
|
+
By default, it is "Ansys, Inc.".
|
|
211
|
+
|
|
212
|
+
The ``--author_maint_email`` is the email of the author and maintainer in the ``pyproject.toml`` file.
|
|
213
|
+
By default, it is "pyansys.core@ansys.com".
|
|
214
|
+
|
|
215
|
+
The ``--license`` argument is the license that is being used by your repository. By default, it is
|
|
216
|
+
MIT.
|
|
217
|
+
|
|
218
|
+
The ``--url`` argument is automatically rendered based on the repository name. If your repository
|
|
219
|
+
is not in the Ansys organization, please add this argument to your configuration in
|
|
220
|
+
.pre-commit-config.yaml.
|
|
221
|
+
|
|
222
|
+
The ``--product`` argument is required if a ``README.rst`` or ``README.md`` file does not
|
|
223
|
+
exist in your repository and you want the template to render correctly. The product
|
|
224
|
+
for ``PyMechanical`` would be ``mechanical``, for example.
|
|
225
|
+
|
|
226
|
+
The ``--non_compliant_name`` flag can be used if your repository does not follow the typical
|
|
227
|
+
naming convention of ``ansys-*-*``.
|
|
228
|
+
|
|
229
|
+
Technical review hook in ``ansys/pre-commit-hooks``' .pre-commit-config.yaml file:
|
|
230
|
+
|
|
231
|
+
.. code:: yaml
|
|
232
|
+
|
|
233
|
+
- repo: https://github.com/ansys/pre-commit-hooks
|
|
234
|
+
rev: v0.4.0
|
|
235
|
+
hooks:
|
|
236
|
+
- id: tech-review
|
|
237
|
+
args:
|
|
238
|
+
- --product=pre_commit_hooks
|
|
239
|
+
- --non_compliant_name
|
|
240
|
+
|
|
241
|
+
Technical review hook in ``PyMechanical``'s .pre-commit-config.yaml file:
|
|
242
|
+
|
|
243
|
+
.. code:: yaml
|
|
244
|
+
|
|
245
|
+
- repo: https://github.com/ansys/pre-commit-hooks
|
|
246
|
+
rev: v0.4.0
|
|
247
|
+
hooks:
|
|
248
|
+
- id: tech-review
|
|
249
|
+
args:
|
|
250
|
+
- --product=mechanical
|
|
251
|
+
|
|
163
252
|
|
|
164
253
|
How to install
|
|
165
254
|
--------------
|
|
@@ -331,3 +420,4 @@ the building requirements and then execute the build module with these commands:
|
|
|
331
420
|
.. _pytest: https://docs.pytest.org/en/stable/
|
|
332
421
|
.. _Sphinx: https://www.sphinx-doc.org/en/master/
|
|
333
422
|
.. _tox: https://tox.wiki/
|
|
423
|
+
|
|
@@ -1,35 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: ansys-pre-commit-hooks
|
|
3
|
-
Version: 0.3.1
|
|
4
|
-
Summary: A Python wrapper to create Ansys-tailored pre-commit hooks
|
|
5
|
-
Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
6
|
-
Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
7
|
-
Requires-Python: >=3.9,<4
|
|
8
|
-
Description-Content-Type: text/x-rst
|
|
9
|
-
Classifier: Development Status :: 4 - Beta
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
-
Classifier: Operating System :: OS Independent
|
|
16
|
-
Requires-Dist: importlib-metadata==7.1.0
|
|
17
|
-
Requires-Dist: reuse==3.0.2
|
|
18
|
-
Requires-Dist: GitPython==3.1.43
|
|
19
|
-
Requires-Dist: ansys-sphinx-theme[autoapi]==0.15.2 ; extra == "doc"
|
|
20
|
-
Requires-Dist: numpydoc==1.7.0 ; extra == "doc"
|
|
21
|
-
Requires-Dist: sphinx==7.3.7 ; extra == "doc"
|
|
22
|
-
Requires-Dist: sphinx-autodoc-typehints==2.1.0 ; extra == "doc"
|
|
23
|
-
Requires-Dist: sphinx-copybutton==0.5.1 ; extra == "doc"
|
|
24
|
-
Requires-Dist: pytest==8.1.1 ; extra == "tests"
|
|
25
|
-
Requires-Dist: pytest-cov==5.0.0 ; extra == "tests"
|
|
26
|
-
Project-URL: Documentation, https://pre-commit-hooks.docs.ansys.com
|
|
27
|
-
Project-URL: Homepage, https://github.com/ansys/pre-commit-hooks
|
|
28
|
-
Project-URL: Source, https://github.com/ansys/pre-commit-hooks
|
|
29
|
-
Project-URL: Tracker, https://github.com/ansys/pre-commit-hooks/issues
|
|
30
|
-
Provides-Extra: doc
|
|
31
|
-
Provides-Extra: tests
|
|
32
|
-
|
|
33
1
|
Ansys pre-commit hooks
|
|
34
2
|
======================
|
|
35
3
|
|pyansys| |python| |pypi| |GH-CI| |MIT| |black| |pre-commit-ci|
|
|
@@ -68,8 +36,8 @@ Currently, these hooks are available:
|
|
|
68
36
|
* ``add-license-headers``: Add missing license headers to files by using
|
|
69
37
|
`REUSE <https://reuse.software/>`_ . To use this hook, you must
|
|
70
38
|
have ``REUSE`` implemented in your repository.
|
|
71
|
-
|
|
72
|
-
|
|
39
|
+
* ``tech-review``: Do a technical review of your repository according to
|
|
40
|
+
`Ansys repository requirements <https://dev.docs.pyansys.com/packaging/structure.html>`_`
|
|
73
41
|
|
|
74
42
|
``add-license-headers`` setup
|
|
75
43
|
-----------------------------
|
|
@@ -116,7 +84,7 @@ Set custom arguments
|
|
|
116
84
|
.. code:: yaml
|
|
117
85
|
|
|
118
86
|
- repo: https://github.com/ansys/pre-commit-hooks
|
|
119
|
-
rev: v0.
|
|
87
|
+
rev: v0.4.0
|
|
120
88
|
hooks:
|
|
121
89
|
- id: add-license-headers
|
|
122
90
|
args: ["--custom_copyright", "custom copyright phrase", "--custom_template", "template_name", "--custom_license", "license_name", "--ignore_license_check", "--start_year", "2023"]
|
|
@@ -161,7 +129,7 @@ the hook should run on, add the necessary regex to the ``files`` line in your
|
|
|
161
129
|
.. code:: yaml
|
|
162
130
|
|
|
163
131
|
- repo: https://github.com/ansys/pre-commit-hooks
|
|
164
|
-
rev: v0.
|
|
132
|
+
rev: v0.4.0
|
|
165
133
|
hooks:
|
|
166
134
|
- id: add-license-headers
|
|
167
135
|
files: '(src|examples|tests|newFolder)/.*\.(py|newExtension)|\.(proto|newExtension)'
|
|
@@ -174,7 +142,7 @@ In .pre-commit-config.yaml:
|
|
|
174
142
|
.. code:: yaml
|
|
175
143
|
|
|
176
144
|
- repo: https://github.com/ansys/pre-commit-hooks
|
|
177
|
-
rev: v0.
|
|
145
|
+
rev: v0.4.0
|
|
178
146
|
hooks:
|
|
179
147
|
- id: add-license-headers
|
|
180
148
|
exclude: |
|
|
@@ -192,6 +160,59 @@ In .pre-commit-config.yaml:
|
|
|
192
160
|
* ``.*\.js`` excludes all .js files in all directories.
|
|
193
161
|
* ``\..*`` excludes all hidden files.
|
|
194
162
|
|
|
163
|
+
``tech-review`` setup
|
|
164
|
+
---------------------
|
|
165
|
+
|
|
166
|
+
These are the default values for the arguments of the tech-review hook:
|
|
167
|
+
|
|
168
|
+
* ``--author_maint_name=ANSYS, Inc.``
|
|
169
|
+
* ``--author_maint_email=pyansys.core@ansys.com``
|
|
170
|
+
* ``--license=MIT``
|
|
171
|
+
* ``--url=https://github.com/ansys/{repo-name}``, replacing ``repo-name`` with the name of the repository
|
|
172
|
+
|
|
173
|
+
The ``--author_maint_name`` is the name of the author and maintainer in the ``pyproject.toml`` file.
|
|
174
|
+
By default, it is "Ansys, Inc.".
|
|
175
|
+
|
|
176
|
+
The ``--author_maint_email`` is the email of the author and maintainer in the ``pyproject.toml`` file.
|
|
177
|
+
By default, it is "pyansys.core@ansys.com".
|
|
178
|
+
|
|
179
|
+
The ``--license`` argument is the license that is being used by your repository. By default, it is
|
|
180
|
+
MIT.
|
|
181
|
+
|
|
182
|
+
The ``--url`` argument is automatically rendered based on the repository name. If your repository
|
|
183
|
+
is not in the Ansys organization, please add this argument to your configuration in
|
|
184
|
+
.pre-commit-config.yaml.
|
|
185
|
+
|
|
186
|
+
The ``--product`` argument is required if a ``README.rst`` or ``README.md`` file does not
|
|
187
|
+
exist in your repository and you want the template to render correctly. The product
|
|
188
|
+
for ``PyMechanical`` would be ``mechanical``, for example.
|
|
189
|
+
|
|
190
|
+
The ``--non_compliant_name`` flag can be used if your repository does not follow the typical
|
|
191
|
+
naming convention of ``ansys-*-*``.
|
|
192
|
+
|
|
193
|
+
Technical review hook in ``ansys/pre-commit-hooks``' .pre-commit-config.yaml file:
|
|
194
|
+
|
|
195
|
+
.. code:: yaml
|
|
196
|
+
|
|
197
|
+
- repo: https://github.com/ansys/pre-commit-hooks
|
|
198
|
+
rev: v0.4.0
|
|
199
|
+
hooks:
|
|
200
|
+
- id: tech-review
|
|
201
|
+
args:
|
|
202
|
+
- --product=pre_commit_hooks
|
|
203
|
+
- --non_compliant_name
|
|
204
|
+
|
|
205
|
+
Technical review hook in ``PyMechanical``'s .pre-commit-config.yaml file:
|
|
206
|
+
|
|
207
|
+
.. code:: yaml
|
|
208
|
+
|
|
209
|
+
- repo: https://github.com/ansys/pre-commit-hooks
|
|
210
|
+
rev: v0.4.0
|
|
211
|
+
hooks:
|
|
212
|
+
- id: tech-review
|
|
213
|
+
args:
|
|
214
|
+
- --product=mechanical
|
|
215
|
+
|
|
195
216
|
|
|
196
217
|
How to install
|
|
197
218
|
--------------
|
|
@@ -363,4 +384,3 @@ the building requirements and then execute the build module with these commands:
|
|
|
363
384
|
.. _pytest: https://docs.pytest.org/en/stable/
|
|
364
385
|
.. _Sphinx: https://www.sphinx-doc.org/en/master/
|
|
365
386
|
.. _tox: https://tox.wiki/
|
|
366
|
-
|
|
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
|
|
|
5
5
|
[project]
|
|
6
6
|
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
|
|
7
7
|
name = "ansys-pre-commit-hooks"
|
|
8
|
-
version = "0.
|
|
8
|
+
version = "0.4.0"
|
|
9
9
|
description = "A Python wrapper to create Ansys-tailored pre-commit hooks"
|
|
10
10
|
readme = "README.rst"
|
|
11
11
|
requires-python = ">=3.9,<4"
|
|
@@ -27,21 +27,25 @@ classifiers = [
|
|
|
27
27
|
"Operating System :: OS Independent",
|
|
28
28
|
]
|
|
29
29
|
dependencies = [
|
|
30
|
-
"importlib-metadata==7.1.0",
|
|
31
|
-
"reuse==3.0.2",
|
|
32
30
|
"GitPython==3.1.43",
|
|
31
|
+
"importlib-metadata==8.0.0",
|
|
32
|
+
"Jinja2==3.1.4",
|
|
33
|
+
"reuse==3.0.2",
|
|
34
|
+
"requests==2.32.3",
|
|
35
|
+
"semver==3.0.2",
|
|
36
|
+
"toml==0.10.2",
|
|
33
37
|
]
|
|
34
38
|
|
|
35
39
|
[project.optional-dependencies]
|
|
36
40
|
tests = [
|
|
37
|
-
"pytest==8.
|
|
41
|
+
"pytest==8.2.2",
|
|
38
42
|
"pytest-cov==5.0.0",
|
|
39
43
|
]
|
|
40
44
|
doc = [
|
|
41
|
-
"ansys-sphinx-theme[autoapi]==0.
|
|
45
|
+
"ansys-sphinx-theme[autoapi]==0.16.6",
|
|
42
46
|
"numpydoc==1.7.0",
|
|
43
47
|
"sphinx==7.3.7",
|
|
44
|
-
"sphinx-autodoc-typehints==2.
|
|
48
|
+
"sphinx-autodoc-typehints==2.2.2",
|
|
45
49
|
"sphinx-copybutton==0.5.1",
|
|
46
50
|
]
|
|
47
51
|
|
|
@@ -51,6 +55,7 @@ name = "ansys.pre_commit_hooks"
|
|
|
51
55
|
|
|
52
56
|
[project.scripts]
|
|
53
57
|
add-license-headers = "ansys.pre_commit_hooks.add_license_headers:main"
|
|
58
|
+
tech-review = "ansys.pre_commit_hooks.tech_review:main"
|
|
54
59
|
|
|
55
60
|
[project.urls]
|
|
56
61
|
Source = "https://github.com/ansys/pre-commit-hooks"
|
|
@@ -58,7 +63,6 @@ Tracker = "https://github.com/ansys/pre-commit-hooks/issues"
|
|
|
58
63
|
Homepage = "https://github.com/ansys/pre-commit-hooks"
|
|
59
64
|
Documentation = "https://pre-commit-hooks.docs.ansys.com"
|
|
60
65
|
|
|
61
|
-
|
|
62
66
|
[tool.black]
|
|
63
67
|
line-length = 100
|
|
64
68
|
|
|
@@ -66,9 +70,11 @@ line-length = 100
|
|
|
66
70
|
profile = "black"
|
|
67
71
|
force_sort_within_sections = true
|
|
68
72
|
line_length = 100
|
|
69
|
-
default_section = "THIRDPARTY"
|
|
70
73
|
src_paths = ["doc", "src", "tests"]
|
|
71
74
|
|
|
75
|
+
[tool.codespell]
|
|
76
|
+
ignore-words = "doc/styles/config/vocabularies/ANSYS/accept.txt"
|
|
77
|
+
|
|
72
78
|
[tool.coverage.run]
|
|
73
79
|
source = ["ansys.pre_commit_hooks"]
|
|
74
80
|
|
|
@@ -81,6 +87,10 @@ addopts = "--cov=ansys.pre_commit_hooks --cov-report term-missing -vv"
|
|
|
81
87
|
testpaths = [
|
|
82
88
|
"tests",
|
|
83
89
|
]
|
|
90
|
+
markers = [
|
|
91
|
+
"license_headers: marks tests for add-license-headers hook",
|
|
92
|
+
"tech_review: marks tests for tech-review hook",
|
|
93
|
+
]
|
|
84
94
|
|
|
85
95
|
[tool.towncrier]
|
|
86
96
|
package = "ansys.pre_commit_hooks"
|
|
@@ -115,4 +125,4 @@ showcontent = true
|
|
|
115
125
|
[[tool.towncrier.type]]
|
|
116
126
|
directory = "miscellaneous"
|
|
117
127
|
name = "Miscellaneous"
|
|
118
|
-
showcontent = true
|
|
128
|
+
showcontent = true
|
|
@@ -251,14 +251,7 @@ def set_header_args(
|
|
|
251
251
|
return args
|
|
252
252
|
|
|
253
253
|
|
|
254
|
-
def
|
|
255
|
-
changed_headers: int,
|
|
256
|
-
parser: argparse.ArgumentParser,
|
|
257
|
-
values: dict,
|
|
258
|
-
proj: project.Project,
|
|
259
|
-
missing_headers: list,
|
|
260
|
-
i: int,
|
|
261
|
-
) -> int:
|
|
254
|
+
def non_recursive_file_check(changed_headers, parser, values, proj, missing_headers):
|
|
262
255
|
"""
|
|
263
256
|
Check if the committed file is missing its header.
|
|
264
257
|
|
|
@@ -328,6 +321,89 @@ def check_exists(
|
|
|
328
321
|
return changed_headers
|
|
329
322
|
|
|
330
323
|
|
|
324
|
+
def recursive_file_check(changed_headers, parser, values, proj, missing_headers, count):
|
|
325
|
+
"""
|
|
326
|
+
Check if the committed file is missing its header.
|
|
327
|
+
|
|
328
|
+
Parameters
|
|
329
|
+
----------
|
|
330
|
+
changed_headers: int
|
|
331
|
+
``0`` if no headers were added or updated.
|
|
332
|
+
``1`` if headers were added or updated.
|
|
333
|
+
parser: argparse.ArgumentParser
|
|
334
|
+
Parser containing default license header arguments.
|
|
335
|
+
values: dict
|
|
336
|
+
Dictionary containing the values of files, copyright,
|
|
337
|
+
template, license, changed_headers, year, and git_repo.
|
|
338
|
+
proj: project.Project
|
|
339
|
+
Project to run `REUSE <https://reuse.software/>`_ on.
|
|
340
|
+
missing_headers: list
|
|
341
|
+
Committed files that are missing copyright and/or
|
|
342
|
+
license information in their headers.
|
|
343
|
+
count: int
|
|
344
|
+
Integer of the location in the files array.
|
|
345
|
+
|
|
346
|
+
Returns
|
|
347
|
+
-------
|
|
348
|
+
int
|
|
349
|
+
``0`` if all files contain headers and are up to date.
|
|
350
|
+
``1`` if ``REUSE`` changed all noncompliant files.
|
|
351
|
+
"""
|
|
352
|
+
files = values["files"]
|
|
353
|
+
start_year = values["start_year"]
|
|
354
|
+
current_year = values["current_year"]
|
|
355
|
+
copyright = values["copyright"]
|
|
356
|
+
template = values["template"]
|
|
357
|
+
|
|
358
|
+
if count < len(files):
|
|
359
|
+
# If the committed file is in missing_headers
|
|
360
|
+
file = files[count]
|
|
361
|
+
|
|
362
|
+
if (file in missing_headers) or (os.path.getsize(file) == 0):
|
|
363
|
+
changed_headers = 1
|
|
364
|
+
# Run REUSE on the file
|
|
365
|
+
args = set_header_args(parser, start_year, current_year, file, copyright, template)
|
|
366
|
+
if not args.ignore_license_check:
|
|
367
|
+
args.license = [values["license"]]
|
|
368
|
+
_annotate.run(args, proj)
|
|
369
|
+
|
|
370
|
+
# Check if the next file is in missing_headers
|
|
371
|
+
return recursive_file_check(
|
|
372
|
+
changed_headers, parser, values, proj, missing_headers, count + 1
|
|
373
|
+
)
|
|
374
|
+
else:
|
|
375
|
+
# Save current copy of file
|
|
376
|
+
before_hook = NamedTemporaryFile(mode="w", delete=False).name
|
|
377
|
+
shutil.copyfile(file, before_hook)
|
|
378
|
+
|
|
379
|
+
# Update the header
|
|
380
|
+
# tmp captures the stdout of the header.run() function
|
|
381
|
+
with NamedTemporaryFile(mode="w", delete=True) as tmp:
|
|
382
|
+
args = set_header_args(parser, start_year, current_year, file, copyright, template)
|
|
383
|
+
_annotate.run(args, proj, tmp)
|
|
384
|
+
|
|
385
|
+
# Check if the file before add-license-headers was run is the same as the one
|
|
386
|
+
# after add-license-headers was run. If not, apply the syntax changes
|
|
387
|
+
# from other hooks before add-license-headers was run to the file
|
|
388
|
+
if check_same_content(before_hook, file) == False:
|
|
389
|
+
add_hook_changes(before_hook, file)
|
|
390
|
+
|
|
391
|
+
# Check if the file content before add-license-headers was run has been changed
|
|
392
|
+
# Assuming the syntax was fixed in the above if statement, this check is
|
|
393
|
+
# solely for the file's content
|
|
394
|
+
if check_same_content(before_hook, file) == False:
|
|
395
|
+
changed_headers = 1
|
|
396
|
+
print(f"Successfully changed header of {file}")
|
|
397
|
+
|
|
398
|
+
os.remove(before_hook)
|
|
399
|
+
|
|
400
|
+
return recursive_file_check(
|
|
401
|
+
changed_headers, parser, values, proj, missing_headers, count + 1
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
return changed_headers
|
|
405
|
+
|
|
406
|
+
|
|
331
407
|
def check_same_content(before_hook, after_hook):
|
|
332
408
|
"""
|
|
333
409
|
Check if file before the hook ran is the same as after the hook ran.
|
|
@@ -635,7 +711,14 @@ def find_files_missing_header() -> int:
|
|
|
635
711
|
|
|
636
712
|
# Add or update headers of required files.
|
|
637
713
|
# Return 1 if files were added or updated, and return 0 if no files were altered.
|
|
638
|
-
|
|
714
|
+
if len(values["files"]) <= (sys.getrecursionlimit() - 2):
|
|
715
|
+
file_return_code = recursive_file_check(
|
|
716
|
+
changed_headers, parser, values, proj, missing_headers, 0
|
|
717
|
+
)
|
|
718
|
+
else:
|
|
719
|
+
file_return_code = non_recursive_file_check(
|
|
720
|
+
changed_headers, parser, values, proj, missing_headers
|
|
721
|
+
)
|
|
639
722
|
|
|
640
723
|
# Unlink default files & remove .reuse and LICENSES folders if empty
|
|
641
724
|
cleanup(assets, os_git_root)
|