A pasbuild plugin that checks and fixes copyright headers in Pascal (.pas) source files tracked by git.
Project page: https://github.com/andrewd207/pasbuild-copyright
Once installed, the plugin is invoked through pasbuild:
pasbuild copyright-check
pasbuild copyright-fixpasbuild discovers the plugin automatically from its plugin directory and dispatches to the appropriate mode.
-
copyright-check— scans all git-tracked.pasfiles and exits with a non-zero status if any file is missing a copyright header or has one with an out-of-date year. -
copyright-fix— same scan, but automatically inserts missing headers or updates stale years in-place. Requires a clean git working tree (no staged or unstaged changes).
The tool looks for a copyright line within the first 20 lines of each file. A line is recognised as a copyright if it contains the word copyright, (c), or © (case-insensitive).
Build the project with pasbuild, then run the resulting binary with --install-plugin:
./target/pasbuild-copyright --install-pluginThis copies the binary into the pasbuild plugins directory as both pasbuild-copyright-check and pasbuild-copyright-fix:
~/.pasbuild/plugins/pasbuild-copyright-check
~/.pasbuild/plugins/pasbuild-copyright-fixAfter that, pasbuild copyright-check and pasbuild copyright-fix will work from any project directory.
PASBUILD_COPYRIGHT_FILE-
Path to the copyright template file to use when inserting a new header. If not set, the plugin falls back to
resources/copyright_stub.txtin the current directory. The file must contain the wordcopyright(case-insensitive) or it will be rejected. PASBUILD_COPYRIGHT_AUTHOR-
The author name substituted for
$whoin the template file. Required when the template contains$who. PASBUILD_COPYRIGHT_BLACKLIST-
Path to the blacklist file. If not set, the plugin falls back to
resources/copyright_blacklist.txtin the current directory. If the file does not exist no files are excluded.
The template file is a plain text file containing the full copyright block to prepend to a Pascal file, including comment delimiters. Two variables are substituted at runtime:
$year-
Replaced with the current four-digit year.
$who-
Replaced with the value of
PASBUILD_COPYRIGHT_AUTHOR.
The file resources/copyright_stub.txt in this repository is an example:
{
pasbuild-copyright - A plugin for pasbuild to help administer copyright
Copyright (c) $year $who
SPDX-License-Identifier: BSD-3-Clause
Licensed under the BSD 3-Clause License. See LICENSE file for details.
}Copy and adapt it for your own project, then point PASBUILD_COPYRIGHT_FILE at it.
If no template is configured and no resources/copyright_stub.txt exists, copyright-fix will attempt to build one automatically from the information it can discover:
-
The project name is read from
pasbuild resolve(requires pasbuild to be on thePATH). -
The SPDX license identifier is taken from the detected root license file.
-
The author is taken from
PASBUILD_COPYRIGHT_AUTHORor extracted from the root license file.
The generated header follows the same format as the example above. Any field that cannot be determined is omitted. If the author cannot be resolved and $who would appear in the result, copyright-fix exits with an error.
The blacklist file lists regular expression patterns (one per line) matched against the file path. Any file whose path matches a pattern is skipped entirely — no check or fix is applied.
Path separators are normalised to / before matching, so patterns only need to use / regardless of whether the OS uses / or \.
Lines starting with // or # are treated as comments and ignored, as are blank lines. Invalid regex patterns are skipped.
The default location is resources/copyright_blacklist.txt in the current directory. Set PASBUILD_COPYRIGHT_BLACKLIST to use a different path. If the file does not exist, no files are excluded.
Example blacklist:
// ignore all files under a vendor directory (works on both / and \ systems)
vendor/
# ignore generated files in a specific directory
src/generated/.*\.pas$
# ignore a single file by exact path
src/main/pascal/GeneratedCode\.pas$When run directly (outside of pasbuild) the binary accepts explicit command-line arguments:
--install-plugin-
Copies the binary into the pasbuild plugins directory as both
pasbuild-copyright-checkandpasbuild-copyright-fix. --change-license <stub-file>-
Replaces the copyright header in every git-tracked
.pasfile with a fresh one rendered from<stub-file>. Must be run from the project root (the directory that containsproject.xml). Requires a completely clean git working tree — no staged or unstaged changes. The same$yearand$whovariables are supported as in the template file../target/pasbuild-copyright --change-license resources/new_copyright_stub.txt
For files whose header is a block comment (
{…}or(…)), the entire block is removed and replaced. For line-comment headers (//), only the copyright line itself is replaced.
When $who is used in a template and PASBUILD_COPYRIGHT_AUTHOR is not set, the plugin looks for a copyright line in the root license file (e.g. LICENSE) and extracts the author name from it:
Copyright (c) 2026 Andrew Haines → author = "Andrew Haines"
Copyright (c) 2022-2026, Corp Ltd → author = "Corp Ltd"The plugin scans for a license file in each file’s directory and in the project root. Recognised file names: LICENSE, LICENSE.txt, LICENSE.md, LICENSE.rst, LICENCE, LICENCE.txt, LICENCE.md, COPYING, COPYING.txt, COPYING.lesser, COPYRIGHT.
The detected license type is shown in brackets after each filename, e.g. [BSD-3]. Recognised license types and their display names:
| License | Display |
|---|---|
MIT License |
|
ISC License |
|
BSD 2-Clause |
|
BSD 3-Clause |
|
Apache 2.0 |
|
Mozilla Public License 2.0 |
|
GNU LGPL v2/v2.1 |
|
GNU LGPL v3 |
|
GNU GPL v2 |
|
GNU GPL v3 |
|
GNU AGPL v3 |
|
Proprietary (inferred) |
|
Unrecognised |
(not shown) |
A warning is emitted when a subdirectory contains its own license file whose type differs from the root license, and when no license file is found in the project root at all.
The plugin scans the copyright line from right to left and replaces the rightmost four-digit number (≥ 1900) with the current year. Scanning right-to-left means year ranges work correctly:
Copyright (c) 2022-2025 My Name → Copyright (c) 2022-2026 My Name ✔A single year also works as before:
Copyright (c) 2025 My Name → Copyright (c) 2026 My Name ✔