ansys-pre-commit-hooks 0.5.0__tar.gz → 0.5.1__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.
Files changed (35) hide show
  1. {ansys_pre_commit_hooks-0.5.0/src/ansys_pre_commit_hooks.egg-info → ansys_pre_commit_hooks-0.5.1}/PKG-INFO +6 -6
  2. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/README.rst +5 -5
  3. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/pyproject.toml +4 -5
  4. ansys_pre_commit_hooks-0.5.1/src/ansys/pre_commit_hooks/VERSION +1 -0
  5. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/__pycache__/__init__.cpython-310.pyc +0 -0
  6. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/__pycache__/tech_review.cpython-310.pyc +0 -0
  7. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/add_license_headers.py +91 -53
  8. ansys_pre_commit_hooks-0.5.0/src/ansys/pre_commit_hooks/assets/LICENSES/MIT.txt → ansys_pre_commit_hooks-0.5.1/src/ansys/pre_commit_hooks/templates/LICENSE +2 -2
  9. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1/src/ansys_pre_commit_hooks.egg-info}/PKG-INFO +6 -6
  10. ansys_pre_commit_hooks-0.5.0/src/ansys/pre_commit_hooks/VERSION +0 -1
  11. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/AUTHORS +0 -0
  12. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/LICENSE +0 -0
  13. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/MANIFEST.in +0 -0
  14. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/setup.cfg +0 -0
  15. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/setup.py +0 -0
  16. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/__init__.py +0 -0
  17. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/assets/.reuse/templates/ansys.jinja2 +0 -0
  18. /ansys_pre_commit_hooks-0.5.0/src/ansys/pre_commit_hooks/templates/LICENSE → /ansys_pre_commit_hooks-0.5.1/src/ansys/pre_commit_hooks/assets/LICENSES/MIT.txt +0 -0
  19. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/assets/licenses.json +0 -0
  20. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/tech_review.py +0 -0
  21. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/templates/AUTHORS +0 -0
  22. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/templates/CODE_OF_CONDUCT.md +0 -0
  23. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/templates/CONTRIBUTING.md +0 -0
  24. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/templates/CONTRIBUTORS.md +0 -0
  25. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/templates/README.md +0 -0
  26. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/templates/README.rst +0 -0
  27. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys/pre_commit_hooks/templates/dependabot.yml +0 -0
  28. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys_pre_commit_hooks.egg-info/SOURCES.txt +0 -0
  29. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys_pre_commit_hooks.egg-info/dependency_links.txt +0 -0
  30. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys_pre_commit_hooks.egg-info/entry_points.txt +0 -0
  31. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys_pre_commit_hooks.egg-info/requires.txt +0 -0
  32. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/src/ansys_pre_commit_hooks.egg-info/top_level.txt +0 -0
  33. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/tests/test_add_license_headers.py +0 -0
  34. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/tests/test_metadata.py +0 -0
  35. {ansys_pre_commit_hooks-0.5.0 → ansys_pre_commit_hooks-0.5.1}/tests/test_tech_review.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ansys-pre-commit-hooks
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: A Python wrapper to create Ansys-tailored pre-commit hooks
5
5
  Home-page: https://github.com/ansys/pre-commit-hooks
6
6
  Author: ANSYS, Inc.
@@ -140,7 +140,7 @@ Set custom arguments
140
140
  .. code:: yaml
141
141
 
142
142
  - repo: https://github.com/ansys/pre-commit-hooks
143
- rev: v0.5.0
143
+ rev: v0.5.1
144
144
  hooks:
145
145
  - id: add-license-headers
146
146
  args: ["--custom_copyright", "custom copyright phrase", "--custom_template", "template_name", "--custom_license", "license_name", "--ignore_license_check", "--start_year", "2023"]
@@ -185,7 +185,7 @@ the hook should run on, add the necessary regex to the ``files`` line in your
185
185
  .. code:: yaml
186
186
 
187
187
  - repo: https://github.com/ansys/pre-commit-hooks
188
- rev: v0.5.0
188
+ rev: v0.5.1
189
189
  hooks:
190
190
  - id: add-license-headers
191
191
  files: '(src|examples|tests|newFolder)/.*\.(py|newExtension)|\.(proto|newExtension)'
@@ -198,7 +198,7 @@ In .pre-commit-config.yaml:
198
198
  .. code:: yaml
199
199
 
200
200
  - repo: https://github.com/ansys/pre-commit-hooks
201
- rev: v0.5.0
201
+ rev: v0.5.1
202
202
  hooks:
203
203
  - id: add-license-headers
204
204
  exclude: |
@@ -251,7 +251,7 @@ Technical review hook in ``ansys/pre-commit-hooks``' .pre-commit-config.yaml fil
251
251
  .. code:: yaml
252
252
 
253
253
  - repo: https://github.com/ansys/pre-commit-hooks
254
- rev: v0.5.0
254
+ rev: v0.5.1
255
255
  hooks:
256
256
  - id: tech-review
257
257
  args:
@@ -263,7 +263,7 @@ Technical review hook in ``PyMechanical``'s .pre-commit-config.yaml file:
263
263
  .. code:: yaml
264
264
 
265
265
  - repo: https://github.com/ansys/pre-commit-hooks
266
- rev: v0.5.0
266
+ rev: v0.5.1
267
267
  hooks:
268
268
  - id: tech-review
269
269
  args:
@@ -84,7 +84,7 @@ Set custom arguments
84
84
  .. code:: yaml
85
85
 
86
86
  - repo: https://github.com/ansys/pre-commit-hooks
87
- rev: v0.5.0
87
+ rev: v0.5.1
88
88
  hooks:
89
89
  - id: add-license-headers
90
90
  args: ["--custom_copyright", "custom copyright phrase", "--custom_template", "template_name", "--custom_license", "license_name", "--ignore_license_check", "--start_year", "2023"]
@@ -129,7 +129,7 @@ the hook should run on, add the necessary regex to the ``files`` line in your
129
129
  .. code:: yaml
130
130
 
131
131
  - repo: https://github.com/ansys/pre-commit-hooks
132
- rev: v0.5.0
132
+ rev: v0.5.1
133
133
  hooks:
134
134
  - id: add-license-headers
135
135
  files: '(src|examples|tests|newFolder)/.*\.(py|newExtension)|\.(proto|newExtension)'
@@ -142,7 +142,7 @@ In .pre-commit-config.yaml:
142
142
  .. code:: yaml
143
143
 
144
144
  - repo: https://github.com/ansys/pre-commit-hooks
145
- rev: v0.5.0
145
+ rev: v0.5.1
146
146
  hooks:
147
147
  - id: add-license-headers
148
148
  exclude: |
@@ -195,7 +195,7 @@ Technical review hook in ``ansys/pre-commit-hooks``' .pre-commit-config.yaml fil
195
195
  .. code:: yaml
196
196
 
197
197
  - repo: https://github.com/ansys/pre-commit-hooks
198
- rev: v0.5.0
198
+ rev: v0.5.1
199
199
  hooks:
200
200
  - id: tech-review
201
201
  args:
@@ -207,7 +207,7 @@ Technical review hook in ``PyMechanical``'s .pre-commit-config.yaml file:
207
207
  .. code:: yaml
208
208
 
209
209
  - repo: https://github.com/ansys/pre-commit-hooks
210
- rev: v0.5.0
210
+ rev: v0.5.1
211
211
  hooks:
212
212
  - id: tech-review
213
213
  args:
@@ -43,12 +43,11 @@ markers = [
43
43
  [tool.towncrier]
44
44
  package = "ansys.pre_commit_hooks"
45
45
  directory = "doc/changelog.d"
46
- filename = "CHANGELOG.md"
47
- start_string = "<!-- towncrier release notes start -->\n"
48
- underlines = ["", "", ""]
46
+ filename = "doc/source/changelog.rst"
47
+ start_string = ".. towncrier release notes start\n"
49
48
  template = "doc/changelog.d/changelog_template.jinja"
50
- title_format = "## [{version}](https://github.com/ansys/pre-commit-hooks/releases/tag/v{version}) - {project_date}"
51
- issue_format = "[#{issue}](https://github.com/ansys/pre-commit-hooks/pull/{issue})"
49
+ title_format = "`{version} <https://github.com/ansys/pre-commit-hooks/releases/tag/v{version}>`_ - {project_date}"
50
+ issue_format = "`#{issue} <https://github.com/ansys/pre-commit-hooks/pull/{issue}>`_"
52
51
 
53
52
  [[tool.towncrier.type]]
54
53
  directory = "added"
@@ -33,6 +33,7 @@ import re
33
33
  import shutil
34
34
  import sys
35
35
  from tempfile import NamedTemporaryFile
36
+ from typing import IO, Union
36
37
 
37
38
  import git
38
39
  from jinja2 import Environment, FileSystemLoader
@@ -129,49 +130,58 @@ def get_full_paths(file_list: list) -> list:
129
130
  return full_path_files
130
131
 
131
132
 
132
- def update_license_file(arg_dict: dict) -> int:
133
+ def update_license_file(repo_license_path: Path, year_span: str) -> int:
133
134
  """
134
135
  Update the LICENSE file to match MIT.txt, adjusting the year span for each repository.
135
136
 
136
137
  Parameters
137
138
  ----------
138
- arg_dict: dict
139
- Dictionary containing the committed files, custom copyright, template, license,
140
- changed_headers, start & end year, and git_repo
141
- """
142
- # Get location of LICENSE file in the repository the hook runs on
143
- git_root = arg_dict["git_repo"].git.rev_parse("--show-toplevel")
144
- repo_license_loc = Path(git_root) / "LICENSE"
145
- save_repo_license = Path(shutil.copyfile(repo_license_loc, f"{repo_license_loc}_save"))
146
-
147
- # Get the location of MIT.txt in the hook's assets folder
148
- hook_loc = Path(__file__).parent.resolve()
149
- hook_license_file = hook_loc / "assets" / "LICENSES" / f"{DEFAULT_LICENSE}.txt"
150
-
151
- # Copy MIT.txt from the assets folder to the LICENSE file in the repository
152
- if repo_license_loc.is_file() and (arg_dict["license"] == DEFAULT_LICENSE):
153
- generate_license_file(hook_license_file.parent, arg_dict["current_year"], repo_license_loc)
139
+ repo_license_path: Path
140
+ Path to the LICENSE file in the repository.
141
+ year_span: str
142
+ The user start year to the current year. If they are the same, default to the current year.
154
143
 
144
+ Returns
145
+ -------
146
+ int
147
+ ``0`` if the year in the LICENSE file was not updated.
148
+ ``1`` if the year in the LICENSE file was updated.
149
+ """
155
150
  # Whether or not the year in LICENSE was updated
156
151
  # 0 is unchanged, 1 is changed
157
152
  changed = 0
158
153
 
159
- user_start_year = str(arg_dict["start_year"])
160
- current_year = str(arg_dict["current_year"])
154
+ # Temporary file to compare against the updated LICENSE file
155
+ temp_file = NamedTemporaryFile(mode="w", delete=False).name
156
+ shutil.copyfile(repo_license_path, temp_file)
161
157
 
162
- # Check if custom_license is MIT
163
- if repo_license_loc.is_file() and (arg_dict["license"] == DEFAULT_LICENSE):
164
- changed = update_year_range(
165
- changed, repo_license_loc, YEAR_REGEX, user_start_year, current_year
166
- )
158
+ # The year regex to match the year or year range in the LICENSE file
159
+ year_regex = r"(\d{4}) - (\d{4})|\d{4}"
160
+
161
+ with Path(repo_license_path).open(encoding="utf-8", newline="", mode="r") as file:
162
+ lines = file.readlines()
163
+ content = "".join(lines)
164
+
165
+ # Get the first instance of the year range, either one year or a range of years
166
+ year_range_match = re.search(year_regex, content)
167
+ # Get the group from the year_range_match
168
+ year_range = year_range_match.group()
169
+
170
+ # Replace the current year span with the updated year span
171
+ if year_range != year_span:
172
+ # Update the year span in the LICENSE file. "1" is the max number of replacements
173
+ content = re.sub(year_regex, year_span, content, 1)
174
+
175
+ with repo_license_path.open(encoding="utf-8", newline="", mode="w") as file:
176
+ file.write(content)
167
177
 
168
178
  # If the year changed, print a message that the LICENSE file was changed
169
- if not check_same_content(save_repo_license, repo_license_loc):
179
+ if not check_same_content(temp_file, repo_license_path):
170
180
  changed = 1
171
- print(f"Successfully updated year in {repo_license_loc}")
181
+ print(f"Successfully updated year in {repo_license_path}")
172
182
 
173
183
  # Remove the temporary file
174
- save_repo_license.unlink()
184
+ Path(temp_file).unlink()
175
185
 
176
186
  return changed
177
187
 
@@ -217,16 +227,19 @@ def link_assets(assets: dict, git_root: str, args: argparse.Namespace) -> None:
217
227
  generate_license_file(hook_license_file.parent, dt.today().year, repo_license_file)
218
228
 
219
229
 
220
- def generate_license_file(template_parent_dir, current_year, license_file_name) -> None:
230
+ def generate_license_file(
231
+ template_parent_dir: Path, year_span: int, license_file_name: Path
232
+ ) -> None:
221
233
  """Generate the MIT.txt file from the assets/LICENSES/MIT.txt template.
222
234
 
223
235
  Parameters
224
236
  ----------
225
- template_parent_dir: str
237
+ template_parent_dir: Path
226
238
  Path to the parent directory of the template file.
227
- current_year: int
228
- The current year.
229
- license_file_name: str
239
+ year_span: int
240
+ The user start year to the current year. If they are the same, default to the current year.
241
+ For example, "2024" or "2023 - 2025".
242
+ license_file_name: Path
230
243
  Path to the license file in the repository to generate.
231
244
  """
232
245
  loader = FileSystemLoader(searchpath=template_parent_dir)
@@ -234,7 +247,7 @@ def generate_license_file(template_parent_dir, current_year, license_file_name)
234
247
  # Get the template for the specified file
235
248
  template = env.get_template(f"{DEFAULT_LICENSE}.txt")
236
249
  # Generate the file content from the template
237
- file_content = template.render(current_year=current_year)
250
+ file_content = template.render(year_span=year_span)
238
251
 
239
252
  # Write the file content to the LICENSE file in the repository
240
253
  with license_file_name.open("w") as file:
@@ -306,7 +319,7 @@ def recursive_file_check(
306
319
  if (not file_reuse_info) or (Path(file).stat().st_size == 0):
307
320
  changed_headers = 1
308
321
  # Add the header to the file
309
- add_header(copyright, license, years, file, template, commented)
322
+ add_header(copyright, license, years, file, template, commented, sys.stdout)
310
323
  # Check if the next file is in missing_headers
311
324
  return recursive_file_check(changed_headers, obj, values, args, count + 1)
312
325
  elif file_reuse_info:
@@ -355,7 +368,7 @@ def non_recursive_file_check(
355
368
  # If the file is empty or does not contain reuse information
356
369
  if (not file_reuse_info) or (Path(file).stat().st_size == 0):
357
370
  changed_headers = 1
358
- add_header(copyright, license, years, file, template, commented)
371
+ add_header(copyright, license, years, file, template, commented, sys.stdout)
359
372
  elif file_reuse_info:
360
373
  changed_headers = update_header(
361
374
  changed_headers, file, copyright, license, years, template, commented
@@ -420,7 +433,7 @@ def update_header(
420
433
  license: str
421
434
  The license of the header. For example, "MIT".
422
435
  years: str
423
- The year span of the header. For example, "2024" or "2023 - 2024".
436
+ The year span of the header. For example, "2024" or "2023 - 2025".
424
437
  template: str
425
438
  The template to use for the header. For example, "ansys" for "ansys.jinja2".
426
439
  commented: bool
@@ -443,7 +456,7 @@ def update_header(
443
456
  # Update the header
444
457
  # tmp captures the stdout of the header.run() function
445
458
  with NamedTemporaryFile(mode="w", delete=True) as tmp:
446
- add_header(copyright, license, years, file, template, commented)
459
+ add_header(copyright, license, years, file, template, commented, tmp)
447
460
 
448
461
  # Check if the file before add-license-headers was run is the same as the one
449
462
  # after add-license-headers was run. If not, apply the syntax changes
@@ -451,6 +464,7 @@ def update_header(
451
464
  if check_same_content(before_hook, file) == False:
452
465
  apply_hook_changes(before_hook, file)
453
466
 
467
+ # Update the year span in the header if necessary
454
468
  years_list = years.split(" - ")
455
469
  if len(years_list) == 1:
456
470
  if years_list != DEFAULT_START_YEAR:
@@ -468,13 +482,20 @@ def update_header(
468
482
  changed_headers = 1
469
483
  print(f"Successfully changed header of {file}")
470
484
 
485
+ # Remove the temporary file
471
486
  Path(before_hook).unlink()
472
487
 
473
488
  return changed_headers
474
489
 
475
490
 
476
491
  def add_header(
477
- copyright: str, license: str, years: str, file: str, template: str, commented: bool
492
+ copyright: str,
493
+ license: str,
494
+ years: str,
495
+ file: str,
496
+ template: str,
497
+ commented: bool,
498
+ out: Union[NamedTemporaryFile, IO[str]],
478
499
  ) -> None:
479
500
  """Add the license header to the file.
480
501
 
@@ -486,13 +507,15 @@ def add_header(
486
507
  license: str
487
508
  The license for the license header. For example, "MIT".
488
509
  years: str
489
- The year span in the license header. For example, "2024" or "2023 - 2024".
510
+ The year span in the license header. For example, "2024" or "2023 - 2025".
490
511
  file: str
491
512
  The file path to add the license header to.
492
513
  template: str
493
514
  The template to use for the license header. For example, "ansys.jinja2".
494
515
  commented: bool
495
516
  Whether the template is commented or not.
517
+ tmp: Union[NamedTemporaryFile, IO[str]]
518
+ Temporary file to capture the stdout of the add_header_to_file() function or ``sys.stdout``.
496
519
  """
497
520
  # Get the REUSE information from the file.
498
521
  reuse_info = get_reuse_info(
@@ -511,7 +534,7 @@ def add_header(
511
534
  template_is_commented=commented,
512
535
  style=f"{get_comment_style(file).SHORTHAND}",
513
536
  merge_copyrights=True,
514
- out=sys.stdout,
537
+ out=out,
515
538
  )
516
539
 
517
540
 
@@ -657,7 +680,8 @@ def update_year_range(
657
680
  # the year span in the file isn't the current year, update the header
658
681
  if (user_year_span != match_year_span) and (match_year_span != current_year):
659
682
  changed_headers = 1
660
- content = re.sub(year_regex, user_year_span, content)
683
+ # Update the year span in the header. "1" is the max number of replacements
684
+ content = re.sub(year_regex, user_year_span, content, 1)
661
685
 
662
686
  # Update the file with the new year span
663
687
  with Path(file).open(encoding="utf-8", newline="", mode="w") as write_file:
@@ -729,9 +753,6 @@ def main():
729
753
  parser = argparse.ArgumentParser()
730
754
  args = set_lint_args(parser)
731
755
 
732
- # Get root directory of the git repository.
733
- git_repo = git.Repo(Path.cwd(), search_parent_directories=True)
734
-
735
756
  # Set changed_headers to zero by default
736
757
  changed_headers = 0
737
758
 
@@ -746,6 +767,11 @@ def main():
746
767
  else:
747
768
  raise Exception("Please ensure the start year is a number.")
748
769
 
770
+ # Get root directory of the git repository.
771
+ git_repo = git.Repo(Path.cwd(), search_parent_directories=True)
772
+ # Get the root of the git repository and fix the line separators
773
+ git_root = Path(git_repo.git.rev_parse("--show-toplevel"))
774
+
749
775
  # Create dictionary containing the committed files, custom copyright,
750
776
  # template, license, changed_headers, year, and git_repo
751
777
  values = {
@@ -758,13 +784,6 @@ def main():
758
784
  "git_repo": git_repo,
759
785
  }
760
786
 
761
- # Update the year in the copyright line of the LICENSE file
762
- license_return_code = update_license_file(values)
763
-
764
- # Get the root of the git repository and fix the line separators
765
- git_root = values["git_repo"].git.rev_parse("--show-toplevel")
766
- os_git_root = Path(git_root).resolve()
767
-
768
787
  # Dictionary containing the asset folder information
769
788
  assets = {
770
789
  ".reuse": {
@@ -778,7 +797,26 @@ def main():
778
797
  }
779
798
 
780
799
  # Link the default template and/or license from the assets folder to your git repo.
781
- link_assets(assets, os_git_root, args)
800
+ link_assets(assets, git_root, args)
801
+
802
+ # Set the license return code to zero by default
803
+ license_return_code = 0
804
+ # Get the path to the LICENSE file in the repository
805
+ repo_license_path = git_root / "LICENSE"
806
+
807
+ # Update the year span in the LICENSE file if necessary
808
+ if repo_license_path.is_file() and (args.custom_license == DEFAULT_LICENSE):
809
+ # Create a year span based on user input and the current year
810
+ user_start_year = str(values["start_year"])
811
+ current_year = str(values["current_year"])
812
+ year_span = (
813
+ f"{user_start_year} - {current_year}"
814
+ if user_start_year != current_year
815
+ else current_year
816
+ )
817
+
818
+ # Update the year span in the LICENSE file
819
+ license_return_code = update_license_file(repo_license_path, year_span)
782
820
 
783
821
  # Create click object for the project
784
822
  obj = common.ClickObj(git_root)
@@ -791,7 +829,7 @@ def main():
791
829
  file_return_code = non_recursive_file_check(changed_headers, obj, values, args)
792
830
 
793
831
  # Unlink default files & remove .reuse and LICENSES folders if empty
794
- cleanup(assets, os_git_root)
832
+ cleanup(assets, git_root)
795
833
 
796
834
  # Returns 1 if REUSE changes noncompliant files or the year was updated in LICENSE
797
835
  # Returns 0 if all files are compliant
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) {{ current_year }} ANSYS, Inc. and/or its affiliates.
3
+ Copyright (c) {{ year_span }} ANSYS, Inc. and/or its affiliates.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: ansys-pre-commit-hooks
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: A Python wrapper to create Ansys-tailored pre-commit hooks
5
5
  Home-page: https://github.com/ansys/pre-commit-hooks
6
6
  Author: ANSYS, Inc.
@@ -140,7 +140,7 @@ Set custom arguments
140
140
  .. code:: yaml
141
141
 
142
142
  - repo: https://github.com/ansys/pre-commit-hooks
143
- rev: v0.5.0
143
+ rev: v0.5.1
144
144
  hooks:
145
145
  - id: add-license-headers
146
146
  args: ["--custom_copyright", "custom copyright phrase", "--custom_template", "template_name", "--custom_license", "license_name", "--ignore_license_check", "--start_year", "2023"]
@@ -185,7 +185,7 @@ the hook should run on, add the necessary regex to the ``files`` line in your
185
185
  .. code:: yaml
186
186
 
187
187
  - repo: https://github.com/ansys/pre-commit-hooks
188
- rev: v0.5.0
188
+ rev: v0.5.1
189
189
  hooks:
190
190
  - id: add-license-headers
191
191
  files: '(src|examples|tests|newFolder)/.*\.(py|newExtension)|\.(proto|newExtension)'
@@ -198,7 +198,7 @@ In .pre-commit-config.yaml:
198
198
  .. code:: yaml
199
199
 
200
200
  - repo: https://github.com/ansys/pre-commit-hooks
201
- rev: v0.5.0
201
+ rev: v0.5.1
202
202
  hooks:
203
203
  - id: add-license-headers
204
204
  exclude: |
@@ -251,7 +251,7 @@ Technical review hook in ``ansys/pre-commit-hooks``' .pre-commit-config.yaml fil
251
251
  .. code:: yaml
252
252
 
253
253
  - repo: https://github.com/ansys/pre-commit-hooks
254
- rev: v0.5.0
254
+ rev: v0.5.1
255
255
  hooks:
256
256
  - id: tech-review
257
257
  args:
@@ -263,7 +263,7 @@ Technical review hook in ``PyMechanical``'s .pre-commit-config.yaml file:
263
263
  .. code:: yaml
264
264
 
265
265
  - repo: https://github.com/ansys/pre-commit-hooks
266
- rev: v0.5.0
266
+ rev: v0.5.1
267
267
  hooks:
268
268
  - id: tech-review
269
269
  args: