From bdedad23dd6cf366a86c7598f5d04823af411bfb Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Thu, 7 Sep 2023 11:46:35 -0400 Subject: [PATCH 1/8] run license headers every time for pre-commit --- LICENSE | 21 +++++ src/ansys/pre_commit_hooks/__init__.py | 2 +- .../pre_commit_hooks/add_license_headers.py | 94 ++++++++++--------- 3 files changed, 73 insertions(+), 44 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..afa2b05b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 ANSYS, Inc. and/or its affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/ansys/pre_commit_hooks/__init__.py b/src/ansys/pre_commit_hooks/__init__.py index 423ee989..e5702cca 100644 --- a/src/ansys/pre_commit_hooks/__init__.py +++ b/src/ansys/pre_commit_hooks/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2023 ANSYS, Inc. and/or its affiliates. +# Copyright (C) 2022 - 2023 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # diff --git a/src/ansys/pre_commit_hooks/add_license_headers.py b/src/ansys/pre_commit_hooks/add_license_headers.py index 7e06b51b..db777d56 100644 --- a/src/ansys/pre_commit_hooks/add_license_headers.py +++ b/src/ansys/pre_commit_hooks/add_license_headers.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (C) 2023 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # @@ -106,6 +105,42 @@ def list_noncompliant_files(args, proj): return missing_headers +def set_args_and_run_reuse(parser, loc, year, path): + """ + Set arguments and run `REUSE `_. + + Parameters + ---------- + parser: argparse.ArgumentParser + Parser containing default license header arguments. + loc: str + Location to search for files that are missing license headers. + year: int + Current year retrieved by datetime. + path: str + Directory to update license headers, or a specific file path to + create license headers. + """ + # Provide values for license header arguments + args = parser.parse_args([rf"--loc={loc}", path]) + args.year = [str(year)] + args.copyright_style = "string-c" + args.copyright = ["ANSYS, Inc. and/or its affiliates."] + args.merge_copyrights = True + args.template = "ansys" + args.skip_unrecognised = True + args.parser = parser + args.recursive = True + + # If adding license header for the first time + if os.path.isfile(path): + args.license = ["MIT"] + + # Requires .reuse directory to be in git_root directory + proj = project.Project(repo_path()) + header.run(args, proj) + + def find_files_missing_header(): """ Find files that are missing license headers and run `REUSE `_ on them. @@ -137,11 +172,23 @@ def find_files_missing_header(): # Get current year for license file year = dt.today().year + # Add header arguments to parser. Arguments are: copyright, license, contributor, + # year, style, copyright-style, template, exclude-year, merge-copyrights, single-line, + # multi-line, explicit-license, force-dot-license, recursive, no-replace, + # skip-unrecognized, and skip-existing. + header.add_arguments(parser) + # If there are files missing headers, run REUSE and return 1 if missing_headers: + # Add missing license header to each file in the list + for file in missing_headers: + set_args_and_run_reuse(parser, args.loc, year, file) + # Returns 1 if REUSE changes all noncompliant files - run_reuse(parser, year, args.loc, missing_headers) return 1 + else: + # Run on default directory + set_args_and_run_reuse(parser, args.loc, year, DEFAULT_SOURCE_CODE_DIRECTORY) # Hook ran fine.... returning exit code 0 return 0 @@ -194,8 +241,8 @@ def check_dir_exists(folder_name) -> bool: f"The {folder_name} directory does not exist in {git_root}.", "Please add the --loc flag to .pre-commit-config.yaml, as follows:\n", "- id: add-license-headers", - " args:", - " - --loc=mydir", + " args:", + " - --loc=mydir", "", "Where mydir is a directory containing files that are checked for license headers.", sep=os.linesep, @@ -205,45 +252,6 @@ def check_dir_exists(folder_name) -> bool: return True -def run_reuse(parser, year, loc, missing_headers): - """ - Run `REUSE `_ on files that are missing license headers. - - Parameters - ---------- - parser: argparse.ArgumentParser - Parser containing the previously set arguments. - year: int - Current year for the license header. - loc: str - Location to search for files that are missing license headers. - missing_headers: list - List of files that are missing license headers. - - """ - # Add header arguments to parser. Arguments are: copyright, license, contributor, - # year, style, copyright-style, template, exclude-year, merge-copyrights, single-line, - # multi-line, explicit-license, force-dot-license, recursive, no-replace, - # skip-unrecognized, and skip-existing. - header.add_arguments(parser) - - # Add missing license header to each file in the list - for file in missing_headers: - args = parser.parse_args([rf"--loc={loc}", file]) - args.year = [str(year)] - args.copyright_style = "string-c" - args.copyright = ["ANSYS, Inc. and/or its affiliates."] - args.merge_copyrights = True - args.template = "ansys" - args.license = ["MIT"] - args.skip_unrecognised = True - args.parser = parser - - # Requires .reuse directory to be in git_root directory - proj = project.Project(repo_path()) - header.run(args, proj) - - def main(): """Find files missing license headers and run `REUSE `_ on them.""" return find_files_missing_header() From d4cd0dd833cf32e4c43e3f50d401e778ac4ad22f Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Thu, 7 Sep 2023 11:48:23 -0400 Subject: [PATCH 2/8] fixed init header --- src/ansys/pre_commit_hooks/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/pre_commit_hooks/__init__.py b/src/ansys/pre_commit_hooks/__init__.py index e5702cca..423ee989 100644 --- a/src/ansys/pre_commit_hooks/__init__.py +++ b/src/ansys/pre_commit_hooks/__init__.py @@ -1,4 +1,4 @@ -# Copyright (C) 2022 - 2023 ANSYS, Inc. and/or its affiliates. +# Copyright (C) 2023 ANSYS, Inc. and/or its affiliates. # SPDX-License-Identifier: MIT # # From d8c22d563f6b1dc1f7633fca8fe20a26396b6b7f Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Thu, 7 Sep 2023 13:35:33 -0400 Subject: [PATCH 3/8] allow multiple dirs to run reuse on --- README.rst | 12 +- .../pre_commit_hooks/add_license_headers.py | 181 ++++++++++-------- 2 files changed, 107 insertions(+), 86 deletions(-) diff --git a/README.rst b/README.rst index f094da8b..7c2945f5 100644 --- a/README.rst +++ b/README.rst @@ -67,11 +67,19 @@ Currently, these hooks are available: - repo: https://github.com/ansys/pre-commit-hooks rev: v0.1.0 hooks: + - id: add-license-headers + args: ["--loc", "dir1,dir2"] + + or + + .. code:: yaml + + ... - id: add-license-headers args: - - --loc=mydir + - --loc=dir1,dir2 - Where ``mydir`` is a directory containing files that are checked for license headers. + Where ``dir1`` and ``dir2`` are directories containing files that are checked for license headers. How to install -------------- diff --git a/src/ansys/pre_commit_hooks/add_license_headers.py b/src/ansys/pre_commit_hooks/add_license_headers.py index db777d56..80f7cc96 100644 --- a/src/ansys/pre_commit_hooks/add_license_headers.py +++ b/src/ansys/pre_commit_hooks/add_license_headers.py @@ -65,6 +65,64 @@ def set_lint_args(parser): return parser.parse_args() +def repo_path(): + """ + Get the path to the root of the git repository. + + Returns + ------- + str + Path to the root of the git repository. + """ + git_repo = git.Repo(os.getcwd(), search_parent_directories=True) + git_root = git_repo.git.rev_parse("--show-toplevel") + + return git_root + + +def check_dir_exists(folder_name) -> bool: + """ + Check if the ``.reuse`` or the location directory exist in the root path of the git repo. + + Parameters + ---------- + folder_name: str + Folder to check if it exists. + + Returns + ------- + bool + Returns ``False`` if the ``.reuse`` or ``{folder_name}`` directory do + not exist in the root path of the git repository. Otherwise, ``True``. + """ + # Get root path of git repository + git_root = repo_path() + + # If the .reuse or default_dir directory does not exist in the root + # of the git repository, return 1 + if not os.path.isdir(os.path.join(git_root, ".reuse")): + print( + f"The .reuse directory does not exist in {git_root}.", + "Please copy the .reuse directory from https://github.com/ansys/pre-commit-hooks/.", + sep=os.linesep, + ) + return False + elif not os.path.isdir(os.path.join(git_root, folder_name)): + print( + f"The {folder_name} directory does not exist in {git_root}.", + "Please add the --loc flag to .pre-commit-config.yaml, as follows:\n", + "- id: add-license-headers", + " args:", + " - --loc=mydir", + "", + "Where mydir is a directory containing files that are checked for license headers.", + sep=os.linesep, + ) + return False + else: + return True + + def list_noncompliant_files(args, proj): """ Get a list of the files that are missing license headers. @@ -105,9 +163,9 @@ def list_noncompliant_files(args, proj): return missing_headers -def set_args_and_run_reuse(parser, loc, year, path): +def set_header_args(parser, loc, year, path): """ - Set arguments and run `REUSE `_. + Set arguments for `REUSE `_. Parameters ---------- @@ -132,10 +190,18 @@ def set_args_and_run_reuse(parser, loc, year, path): args.parser = parser args.recursive = True - # If adding license header for the first time - if os.path.isfile(path): - args.license = ["MIT"] + return args + + +def run_reuse(args): + """ + Run `REUSE `_. + Parameters + ---------- + args: argparse.Namespace + Namespace of arguments with their values. + """ # Requires .reuse directory to be in git_root directory proj = project.Project(repo_path()) header.run(args, proj) @@ -158,16 +224,8 @@ def find_files_missing_header(): parser = argparse.ArgumentParser() args = set_lint_args(parser) - # Check if required directories exist - dir_exists = check_dir_exists(args.loc) - if not dir_exists: - # Previous check_dir_exists() function returned error because - # --loc's value does not exist... returning 2 - return 2 - - proj = project.Project(rf"{args.loc}") - - missing_headers = list_noncompliant_files(args, proj) + dirs = args.loc.split(",") + changed_headers = False # Get current year for license file year = dt.today().year @@ -178,78 +236,33 @@ def find_files_missing_header(): # skip-unrecognized, and skip-existing. header.add_arguments(parser) - # If there are files missing headers, run REUSE and return 1 - if missing_headers: - # Add missing license header to each file in the list - for file in missing_headers: - set_args_and_run_reuse(parser, args.loc, year, file) - + # Check if required directories exist + for dir in dirs: + dir_exists = check_dir_exists(dir) + if not dir_exists: + # Previous check_dir_exists() function returned error because + # --loc's value does not exist... returning 2 + return 2 + + proj = project.Project(rf"{dir}") + missing_headers = list_noncompliant_files(args, proj) + + # If there are files missing headers, run REUSE and return 1 + if missing_headers: + changed_headers = True + # Add missing license header to each file in the list + for file in missing_headers: + args = set_header_args(parser, dir, year, file) + # If adding license header for the first time + args.license = ["MIT"] + run_reuse(args) + + if changed_headers: # Returns 1 if REUSE changes all noncompliant files return 1 else: - # Run on default directory - set_args_and_run_reuse(parser, args.loc, year, DEFAULT_SOURCE_CODE_DIRECTORY) - - # Hook ran fine.... returning exit code 0 - return 0 - - -def repo_path(): - """ - Get the path to the root of the git repository. - - Returns - ------- - str - Path to the root of the git repository. - """ - git_repo = git.Repo(os.getcwd(), search_parent_directories=True) - git_root = git_repo.git.rev_parse("--show-toplevel") - - return git_root - - -def check_dir_exists(folder_name) -> bool: - """ - Check if the ``.reuse`` or the location directory exist in the root path of the git repo. - - Parameters - ---------- - folder_name: str - Folder to check if it exists. - - Returns - ------- - bool - Returns ``False`` if the ``.reuse`` or ``{folder_name}`` directory do - not exist in the root path of the git repository. Otherwise, ``True``. - """ - # Get root path of git repository - git_root = repo_path() - - # If the .reuse or default_dir directory does not exist in the root - # of the git repository, return 1 - if not os.path.isdir(os.path.join(git_root, ".reuse")): - print( - f"The .reuse directory does not exist in {git_root}.", - "Please copy the .reuse directory from https://github.com/ansys/pre-commit-hooks/.", - sep=os.linesep, - ) - return False - elif not os.path.isdir(os.path.join(git_root, folder_name)): - print( - f"The {folder_name} directory does not exist in {git_root}.", - "Please add the --loc flag to .pre-commit-config.yaml, as follows:\n", - "- id: add-license-headers", - " args:", - " - --loc=mydir", - "", - "Where mydir is a directory containing files that are checked for license headers.", - sep=os.linesep, - ) - return False - else: - return True + # Hook ran fine.... returning exit code 0 + return 0 def main(): From 5bb0f74eac5428832bf3ebd6e063b856f67abd40 Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Thu, 7 Sep 2023 13:37:45 -0400 Subject: [PATCH 4/8] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b02978a0..8c03d433 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This document follows the conventions laid out in [Keep a CHANGELOG](https://kee ## [Unreleased]() +## Added + +- Allow reuse to run on multiple directories (#43) + ### Changed - Update descriptions for add-license-headers in README (#40) From 16dddfe9f89a4c186ed098a7ff42c7947ce96aba Mon Sep 17 00:00:00 2001 From: Kerry McAdams <58492561+klmcadams@users.noreply.github.com> Date: Thu, 7 Sep 2023 13:44:17 -0400 Subject: [PATCH 5/8] fixed README.rst --- README.rst | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 7c2945f5..f6025ab9 100644 --- a/README.rst +++ b/README.rst @@ -70,17 +70,14 @@ Currently, these hooks are available: - id: add-license-headers args: ["--loc", "dir1,dir2"] - or + Where ``dir1`` and ``dir2`` are directories containing files that are checked for license headers. + ``args`` can also be formatted as follows: - .. code:: yaml + .. code:: yaml - ... - - id: add-license-headers args: - --loc=dir1,dir2 - Where ``dir1`` and ``dir2`` are directories containing files that are checked for license headers. - How to install -------------- From 17724abae4a8290cbff4f55ed50ba0af3c58f221 Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Thu, 7 Sep 2023 17:43:31 -0400 Subject: [PATCH 6/8] added custom flags for loc, license, template, and copyright as well as tests --- README.rst | 11 ++++- .../pre_commit_hooks/add_license_headers.py | 44 ++++++++++++++++--- tests/test_reuse.py | 38 ++++++++++++++++ tests/test_template.jinja2 | 31 +++++++++++++ 4 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 tests/test_template.jinja2 diff --git a/README.rst b/README.rst index f6025ab9..d2c33cca 100644 --- a/README.rst +++ b/README.rst @@ -68,15 +68,22 @@ Currently, these hooks are available: rev: v0.1.0 hooks: - id: add-license-headers - args: ["--loc", "dir1,dir2"] + args: ["--loc", "dir1,dir2", "--custom_copyright", "custom copyright phrase", "--custom_template", "template_name", "--custom_license", "license_name"] + + ``dir1`` and ``dir2`` are directories containing files that are checked for license headers. + ``custom copyright phrase`` is the copyright line you want to include in the license header. + ``template_name`` is the name of the .jinja2 file located in .reuse/templates/ + ``license_name`` is the name of the license being used. For example, MIT, ECL-1.0, etc. To view a list of licenses that are supported by ``REUSE``, see https://github.com/spdx/license-list-data/tree/main/text - Where ``dir1`` and ``dir2`` are directories containing files that are checked for license headers. ``args`` can also be formatted as follows: .. code:: yaml args: - --loc=dir1,dir2 + - --custom_copyright=custom copyright phrase + - --custom_template=template_name + - --custom_license=license_name How to install -------------- diff --git a/src/ansys/pre_commit_hooks/add_license_headers.py b/src/ansys/pre_commit_hooks/add_license_headers.py index 80f7cc96..bdd4e7c7 100644 --- a/src/ansys/pre_commit_hooks/add_license_headers.py +++ b/src/ansys/pre_commit_hooks/add_license_headers.py @@ -36,6 +36,12 @@ DEFAULT_SOURCE_CODE_DIRECTORY = "src" """Default directory to check files for license headers.""" +DEFAULT_TEMPLATE = "ansys" +"""Default template to use for license headers.""" +DEFAULT_COPYRIGHT = "ANSYS, Inc. and/or its affiliates." +"""Default copyright line for license headers.""" +DEFAULT_LICENSE = "MIT" +"""Default license for headers.""" def set_lint_args(parser): @@ -58,6 +64,24 @@ def set_lint_args(parser): help="Directory to check files for license headers.", default=DEFAULT_SOURCE_CODE_DIRECTORY, ) + parser.add_argument( + "--custom_copyright", + type=str, + help="Default copyright line for license headers.", + default=DEFAULT_COPYRIGHT, + ) + parser.add_argument( + "--custom_template", + type=str, + help="Default template to use for license headers.", + default=DEFAULT_TEMPLATE, + ) + parser.add_argument( + "--custom_license", + type=str, + help="Default license for headers.", + default=DEFAULT_LICENSE, + ) parser.add_argument("--parser") parser.add_argument("--no_multiprocessing", action="store_true") lint.add_arguments(parser) @@ -163,7 +187,7 @@ def list_noncompliant_files(args, proj): return missing_headers -def set_header_args(parser, loc, year, path): +def set_header_args(parser, loc, year, path, copyright, template): """ Set arguments for `REUSE `_. @@ -178,14 +202,18 @@ def set_header_args(parser, loc, year, path): path: str Directory to update license headers, or a specific file path to create license headers. + copyright: str + Copyright line for license headers. + template: str + Name of the template for license headers (name.jinja2). """ # Provide values for license header arguments args = parser.parse_args([rf"--loc={loc}", path]) args.year = [str(year)] args.copyright_style = "string-c" - args.copyright = ["ANSYS, Inc. and/or its affiliates."] + args.copyright = [copyright] args.merge_copyrights = True - args.template = "ansys" + args.template = template args.skip_unrecognised = True args.parser = parser args.recursive = True @@ -224,7 +252,11 @@ def find_files_missing_header(): parser = argparse.ArgumentParser() args = set_lint_args(parser) + # Get custom specified directories, copyright, template, and/or license dirs = args.loc.split(",") + copyright = args.custom_copyright + template = args.custom_template + license = args.custom_license changed_headers = False # Get current year for license file @@ -252,13 +284,13 @@ def find_files_missing_header(): changed_headers = True # Add missing license header to each file in the list for file in missing_headers: - args = set_header_args(parser, dir, year, file) + args = set_header_args(parser, dir, year, file, copyright, template) # If adding license header for the first time - args.license = ["MIT"] + args.license = [license] run_reuse(args) if changed_headers: - # Returns 1 if REUSE changes all noncompliant files + # Returns 1 if REUSE changes noncompliant files return 1 else: # Hook ran fine.... returning exit code 0 diff --git a/tests/test_reuse.py b/tests/test_reuse.py index 7b30c9a5..f162afdb 100644 --- a/tests/test_reuse.py +++ b/tests/test_reuse.py @@ -1,5 +1,6 @@ import argparse import os +import shutil import sys import git @@ -150,6 +151,43 @@ def test_default_dir_dne(tmp_path: pytest.TempPathFactory): os.chdir(test_dir) +def test_custom_args(tmp_path: pytest.TempPathFactory): + """Test custom arguments for loc, copyright, template, and license.""" + # Initialize tmp_path as a git repository + git.Repo.init(tmp_path) + + dirs = ["dir1", "dir2"] + template_name = "test_template.jinja2" + template_path = os.path.join(os.getcwd(), "tests", template_name) + reuse_dir = os.path.join(tmp_path, ".reuse", "templates") + + # Create .reuse directory and copy template file to it + os.makedirs(reuse_dir) + shutil.copyfile(f"{template_path}", f"{reuse_dir}/{template_name}") + + # Create directories & files to test + for dir in dirs: + dir_path = os.path.join(tmp_path, dir) + # Create src code directory + os.mkdir(dir_path) + os.chdir(dir_path) + # Add temporary file to directory + create_test_file(dir_path) + os.chdir(tmp_path) + + # Pass in custom arguments + sys.argv[1:] = [ + f"--loc={dirs[0]},{dirs[1]}", + '--custom_copyright="Super cool copyright"', + "--custom_template=test_template", + "--custom_license=ECL-1.0", + ] + res = hook.main() + + # Assert main runs successfully with custom arguments + assert res == 1 + + def test_main_passes(): """Test all files are compliant.""" # Ensure you are always running from root path to repo diff --git a/tests/test_template.jinja2 b/tests/test_template.jinja2 new file mode 100644 index 00000000..fd0800cd --- /dev/null +++ b/tests/test_template.jinja2 @@ -0,0 +1,31 @@ +The Educational Community License + +This Educational Community License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work: + +{% for copyright_line in copyright_lines %} +{{ copyright_line }} +{% endfor %} +{% for expression in spdx_expressions %} +SPDX-License-Identifier: {{ expression }} +{% endfor %} + +Licensed under the Educational Community License version 1.0 + +{% if "ECL-1.0" in spdx_expressions %} + +This Original Work, including software, source code, documents, or other related items, is being provided by the copyright holder(s) subject to the terms of the Educational Community License. By obtaining, using and/or copying this Original Work, you agree that you have read, understand, and will comply with the following terms and conditions of the Educational Community License: + +Permission to use, copy, modify, merge, publish, distribute, and sublicense this Original Work and its documentation, with or without modification, for any purpose, and without fee or royalty to the copyright holder(s) is hereby granted, provided that you include the following on ALL copies of the Original Work or portions thereof, including modifications or derivatives, that you make: + + The full text of the Educational Community License in a location viewable to users of the redistributed or derivative work. + + Any pre-existing intellectual property disclaimers, notices, or terms and conditions. + + Notice of any changes or modifications to the Original Work, including the date the changes were made. + + Any modifications of the Original Work must be distributed in such a manner as to avoid any confusion with the Original Work of the copyright holders. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +The name and trademarks of copyright holder(s) may NOT be used in advertising or publicity pertaining to the Original or Derivative Works without specific, written prior permission. Title to copyright in the Original Work and any associated documentation will at all times remain with the copyright holders. +{% endif %} From 09b7c1d6f428737f789f3b0e5106631cb81a00e0 Mon Sep 17 00:00:00 2001 From: Kerry McAdams Date: Thu, 7 Sep 2023 17:46:52 -0400 Subject: [PATCH 7/8] updated changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c03d433..69b62383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG](https://kee ## Added -- Allow reuse to run on multiple directories (#43) +- Create custom flags for add-license-header (#44) ### Changed From b1a4b043835708c6d5a2d60e26606f6d718d0918 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Fri, 8 Sep 2023 09:20:38 +0200 Subject: [PATCH 8/8] docs: improved README --- README.rst | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index d2c33cca..b6489e86 100644 --- a/README.rst +++ b/README.rst @@ -70,10 +70,15 @@ Currently, these hooks are available: - id: add-license-headers args: ["--loc", "dir1,dir2", "--custom_copyright", "custom copyright phrase", "--custom_template", "template_name", "--custom_license", "license_name"] - ``dir1`` and ``dir2`` are directories containing files that are checked for license headers. - ``custom copyright phrase`` is the copyright line you want to include in the license header. - ``template_name`` is the name of the .jinja2 file located in .reuse/templates/ - ``license_name`` is the name of the license being used. For example, MIT, ECL-1.0, etc. To view a list of licenses that are supported by ``REUSE``, see https://github.com/spdx/license-list-data/tree/main/text + - ``dir1`` and ``dir2`` are directories containing files that are checked for license + headers. By default, it looks for the ``src`` folder. + - ``custom copyright phrase`` is the copyright line you want to include in the license + header. By default, it uses ``"ANSYS, Inc. and/or its affiliates."``. + - ``template_name`` is the name of the .jinja2 file located in ``.reuse/templates/``. + By default, it uses ``ansys``. + - ``license_name`` is the name of the license being used. For example, MIT, ECL-1.0, etc. + To view a list of licenses that are supported by ``REUSE``, see + https://github.com/spdx/license-list-data/tree/main/text. By default it uses ``MIT``. ``args`` can also be formatted as follows: