Skip to content

Commit ab9fa8b

Browse files
dependabot[bot]pyansys-ci-botklmcadams
authored
build(deps): bump reuse from 5.1.1 to 6.2.0 (#361)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Co-authored-by: Kerry McAdams <58492561+klmcadams@users.noreply.github.com> Co-authored-by: kmcadams <kerry.mcadams@ansys.com>
1 parent e18d279 commit ab9fa8b

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bump reuse from 5.1.1 to 6.2.0

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = [
33
"setuptools>=42.0",
44
"GitPython==3.1.46",
55
"Jinja2==3.1.6",
6-
"reuse==5.1.1",
6+
"reuse==6.2.0",
77
"requests==2.32.5",
88
"semver==3.0.4",
99
"toml==0.10.2",
@@ -23,7 +23,7 @@ dependencies = [
2323
"GitPython==3.1.46",
2424
"importlib-metadata==8.7.1",
2525
"Jinja2==3.1.6",
26-
"reuse==5.1.1",
26+
"reuse==6.2.0",
2727
"requests==2.32.5",
2828
"semver==3.0.4",
2929
"toml==0.10.2",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def run(self):
7070
"GitPython==3.1.46",
7171
"importlib-metadata==8.7.1",
7272
"Jinja2==3.1.6",
73-
"reuse==5.1.1",
73+
"reuse==6.2.0",
7474
"requests==2.32.5",
7575
"semver==3.0.4",
7676
"toml==0.10.2",

src/ansys/pre_commit_hooks/add_license_headers.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from reuse import extract
4242
from reuse.cli import common
4343
from reuse.cli.annotate import add_header_to_file, get_comment_style, get_reuse_info, get_template
44+
from reuse.copyright import YearRange
4445

4546
DEFAULT_TEMPLATE = "ansys"
4647
"""Default template to use for license headers."""
@@ -518,12 +519,15 @@ def add_header(
518519
tmp: Union[NamedTemporaryFile, IO[str]]
519520
Temporary file to capture the stdout of the add_header_to_file() function or ``sys.stdout``.
520521
"""
522+
# Create a YearRange object from the years string to pass into the get_reuse_info function
523+
year_range = YearRange.tuple_from_string(years)
524+
521525
# Get the REUSE information from the file.
522526
reuse_info = get_reuse_info(
523527
copyrights=copyright,
524528
licenses=license,
525529
copyright_prefix="string-c",
526-
year=years,
530+
years=year_range,
527531
contributors="",
528532
)
529533

@@ -538,6 +542,15 @@ def add_header(
538542
out=out,
539543
)
540544

545+
# Add a space before and after the year range if there is not already one
546+
with Path(file).open(encoding="utf-8", newline="", mode="r") as read_file:
547+
content = read_file.read()
548+
content = re.sub(r"(\d{4})-(\d{4})", r"\1 - \2", content)
549+
550+
# Write the updated content back to the file
551+
with Path(file).open(encoding="utf-8", newline="", mode="w") as write_file:
552+
write_file.write(content)
553+
541554

542555
def check_same_content(before_hook: str, after_hook: str) -> bool:
543556
"""

0 commit comments

Comments
 (0)