diff --git a/.gitignore b/.gitignore index f87f37e..6877e3a 100644 --- a/.gitignore +++ b/.gitignore @@ -291,3 +291,6 @@ tags [._]*.un~ # End of https://www.toptal.com/developers/gitignore/api/vim,linux,macos,python,emacs + +# Copyright Holder +COPYRIGHT_HOLDER diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index abf726a..ad9d201 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,9 @@ repos: name: Update CONTRIBUTORS.md entry: bash ./scripts/generate_contributors.sh language: system - files: . + pass_filenames: false + always_run: true + stages: [commit] - repo: local hooks: - id: add-spdx diff --git a/Makefile b/Makefile index 152c1f3..6f99ddf 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,9 @@ +# If the `COPYRIGHT_HOLDER` file exists and contains a string shorter than 50 characters, +# use it as the name of the copyright holder. +# If not, fall back to the default value: "Ethersecurity Inc." +copyright_holder ?= $(shell bash scripts/get_copyright.sh) +change_files ?= $(shell bash scripts/get_changed_files.sh) + install-dev: pip install -e .[dev] @@ -9,7 +15,7 @@ lint-license: annotate-SPD: @echo "📎 Annotating files..." - reuse annotate --license MPL-2.0 --copyright "Ethersecurity" $(shell git ls-files '*.py' '*.sh') + reuse annotate --license MPL-2.0 --copyright "${copyright_holder}" ${change_files} pre-commit-refresh: @echo "🧹 Cleaning pre-commit cache..." pre-commit clean diff --git a/README.md b/README.md index 2604504..89e3556 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ The binary will be generated in the `dist/` directory, compressed using UPX (if - Licensed under **MPL-2.0**. - Files include SPDX headers and author metadata. + - Please use the following before committing: ```bash @@ -116,6 +117,31 @@ make add-author --- +### Changing the Copyright Holder + +To change the copyright holder name inserted into source files: + +1. Create a file named `COPYRIGHT_HOLDER` in the root of the repository, and write your name or your organization’s name in it. + For example: + + ```bash + echo "Your Name or Organization" > COPYRIGHT_HOLDER + ``` + + > ⚠️ Note: This file is `.gitignore`'d and should not be committed. + +2. Run `make annotate-SPD` (or the relevant pre-commit hook) to re-annotate modified source files with the new copyright holder name. + + - This target internally calls `reuse annotate` to update SPDX headers. + - Only `.py` and `.sh` files tracked by git are affected. + + ```bash + make annotate-SPD + ``` + +> **Important**: The value in `COPYRIGHT_HOLDER` must be under 50 characters. +--- + ## 🤝 Contributing Contributions are welcome! diff --git a/build.sh b/build.sh index fc6b5c7..e1d4f02 100644 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/fireblocks_cli/__init__.py b/fireblocks_cli/__init__.py index 299cc5a..779c514 100644 --- a/fireblocks_cli/__init__.py +++ b/fireblocks_cli/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/fireblocks_cli/commands/configure.py b/fireblocks_cli/commands/configure.py index db5bb98..0ae4fa6 100644 --- a/fireblocks_cli/commands/configure.py +++ b/fireblocks_cli/commands/configure.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/fireblocks_cli/config.py b/fireblocks_cli/config.py index 97c1c5d..a149d4d 100644 --- a/fireblocks_cli/config.py +++ b/fireblocks_cli/config.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/fireblocks_cli/crypto.py b/fireblocks_cli/crypto.py index 8fe35f1..5776012 100644 --- a/fireblocks_cli/crypto.py +++ b/fireblocks_cli/crypto.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/fireblocks_cli/main.py b/fireblocks_cli/main.py index 11361f7..4dbfe25 100644 --- a/fireblocks_cli/main.py +++ b/fireblocks_cli/main.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/scripts/__init__.py b/scripts/__init__.py index 018852d..4d611ca 100644 --- a/scripts/__init__.py +++ b/scripts/__init__.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/scripts/add_author.py b/scripts/add_author.py index 14348f0..ff6a26d 100644 --- a/scripts/add_author.py +++ b/scripts/add_author.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/scripts/check_signoff.sh b/scripts/check_signoff.sh index bb2378a..86ea3a6 100755 --- a/scripts/check_signoff.sh +++ b/scripts/check_signoff.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 diff --git a/scripts/generate_contributors.sh b/scripts/generate_contributors.sh index 2b449c1..190e7a4 100644 --- a/scripts/generate_contributors.sh +++ b/scripts/generate_contributors.sh @@ -1,11 +1,14 @@ #!/bin/bash -# SPDX-FileCopyrightText: 2025 Ethersecurity +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. # # SPDX-License-Identifier: MPL-2.0 # Author: Shohei KAMON +set -x + +rm CONTRIBUTORS.md echo '# Contributors' > CONTRIBUTORS.md echo "" >> CONTRIBUTORS.md echo "This project is developed with contributions from the following individuals:" >> CONTRIBUTORS.md @@ -13,5 +16,7 @@ echo "" >> CONTRIBUTORS.md echo "" >> CONTRIBUTORS.md echo "" >> CONTRIBUTORS.md -# Get unique contributors in the format: Name +# Sorted in chronological order (oldest first) +# With duplicates removed +# Each entry formatted as "- Name " git log --format='%aN <%aE>' | tac | awk '!seen[$0]++ { print "- " $0 }' >> CONTRIBUTORS.md diff --git a/scripts/get_changed_files.sh b/scripts/get_changed_files.sh new file mode 100644 index 0000000..767da84 --- /dev/null +++ b/scripts/get_changed_files.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. +# +# SPDX-License-Identifier: MPL-2.0 + +# Author: Shohei KAMON + +git status --porcelain | grep -v "^??" | cut -c4- | grep -e "\.sh$" -e "\.py$" diff --git a/scripts/get_copyright.sh b/scripts/get_copyright.sh new file mode 100644 index 0000000..f359fa4 --- /dev/null +++ b/scripts/get_copyright.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2025 Ethersecurity Inc. +# +# SPDX-License-Identifier: MPL-2.0 + +# Author: Shohei KAMON + +if [ ! -s COPYRIGHT_HOLDER ]; then + echo "Ethersecurity Inc." + exit 0 +fi + +val=$(cat COPYRIGHT_HOLDER) + +if [ ${#val} -le 50 ]; then + echo "$val" +else + echo "ERROR: COPYRIGHT_HOLDER is too long (>50 chars)" >&2 + exit 1 +fi