Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4ddf99e
SYS-8665 fix changed files
mmaharjan-ccdc Aug 28, 2026
e7d5657
Merge branch 'main' into SYS-8665-copywrite
mmaharjan-ccdc Aug 28, 2026
066b30b
SYS-8665 fix whitespace splitting
mmaharjan-ccdc Aug 28, 2026
276a4e4
SYS-8665 copywrite alternative
mmaharjan-ccdc Aug 29, 2026
106e921
SYS-8665 co-pilot comments
mmaharjan-ccdc Aug 30, 2026
b3c5b44
SYS-8665 fix BOM issue
mmaharjan-ccdc Aug 30, 2026
37327b3
SYS-8665 heal broken headers
mmaharjan-ccdc Aug 30, 2026
506ffa9
SYS-8665 properly repair corruption of headers
mmaharjan-ccdc Aug 30, 2026
fb2d13d
SYS-8665 allow for both licence and license
mmaharjan-ccdc Aug 31, 2026
2b14bdd
SYS-8665 use hooks.licencecheck
mmaharjan-ccdc Aug 31, 2026
6ab8d52
SYS-8665 Skip symlinks before reading or writing
mmaharjan-ccdc Aug 31, 2026
69ac1c1
SYS-8665 stop damaged header scanning at the first non comment, non b…
mmaharjan-ccdc Aug 31, 2026
4a7e7fc
SYS-8665 do away with copywrite references
mmaharjan-ccdc Aug 31, 2026
2ffe726
SYS-8665 make licence_headers import not dependent
mmaharjan-ccdc Aug 31, 2026
bee3d89
SYS-8665 add unit tests
mmaharjan-ccdc Aug 31, 2026
bd7ee2b
SYS-8665 cleanup unused parameters and arguments
mmaharjan-ccdc Aug 31, 2026
f04a596
SYS-8665 prevents incorrect header placement
mmaharjan-ccdc Aug 31, 2026
871ebea
SYS-8665 fix unpadded header duplication issue
mmaharjan-ccdc Aug 31, 2026
a64660c
SYS-8665 less strict checking for unpadded headings
mmaharjan-ccdc Aug 31, 2026
d52fdcf
SYS-8665 improve importing licence_headers
mmaharjan-ccdc Aug 31, 2026
a1fbc20
SYS-8665 revert to import licence_headers
mmaharjan-ccdc Aug 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/quality_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --statistics
- name: Pytest
run: |
pytest main/githooks.py
pytest main/githooks.py test/test_licence_headers.py
2 changes: 1 addition & 1 deletion .github/workflows/status_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- uses: ./
with:
commitMessage: ${{ env.commit_message }}
licenseCheck: true
licenceCheck: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__pycache__/
*.py[cod]
*$py.class
.pytest_cache/
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The commit will be flagged if it includes certain text files with:
* Tabs
* Missing terminating newline for certain files
* Certain C++ #include patterns and std::exception
* Missing or non-compliant CCDC copyright and license headers (when using the GitHub Action or local copywrite integration)
* Missing or non-compliant CCDC copyright and licence headers (when header validation is enabled)

The commit will also be flagged if the commit message does not include a Jira
ID (unless marked with NO_JIRA or a Copilot Autofix co-author line), or if the
Expand Down Expand Up @@ -52,42 +52,44 @@ headers and file compliance rules in CI.
- uses: ccdc-opensource/commit-hooks@v8
with:
commitMessage: ${{ env.commit_message }}
# Optional: enable CCDC license header validation on PR changed files
licenseCheck: true # default: false (opt-in)
# Optional: enable CCDC licence header validation on PR changed files
licenceCheck: true # default: false (opt-in)
```

A complete workflow template for CI is available in [templates/compliance.yml](templates/compliance.yml).

# Native Git Hooks

To enable CCDC commit checks (Jira ID, CRLF, line endings, DO NOT COMMIT, file size, and automatic copyright headers) globally for all repositories on your machine:
To enable CCDC commit checks (Jira ID, CRLF, line endings, DO NOT COMMIT, file size, and automatic copyright headers):

1. Clone this repository.
2. Run:
```bash
git config --global core.hooksPath <path-to-cloned-repo>/main
```
3. (Optional) Install `copywrite` to automatically add and format CCDC copyright headers on commit:
* **Windows:** `choco install copywrite`
* **macOS:** `brew install hashicorp/tap/copywrite`
* **Linux:** `go install github.com/hashicorp/copywrite@latest`

> **Note:** If `copywrite` is not installed on your machine, native hooks will continue to run all other standard checks and display a gentle warning without failing your commit.

## Configuring Copywrite Behavior

Developers can customise the copywrite hook using Git configuration:

* **Enable / Disable Copywrite:**
2. Configure `core.hooksPath`:
* **Globally (for all repositories on your machine):**
```bash
git config --global core.hooksPath <path-to-cloned-repo>/main
```
* **Locally (for a single repository only):**
Run inside the target repository:
```bash
git config core.hooksPath <path-to-cloned-repo>/main
```
*(Only use `--global` if you want the hooks applied across all repositories.)*
3. (Optional) Enable automatic CCDC copyright and licence header formatting as described below.

## Configuring Licence Header Behavior

Developers can customise the licence header hook using Git configuration (use `--global` for all repos, or omit it within a specific repo):

* **Enable / Disable Header Formatting:**
```bash
git config --global hooks.copywrite true # opt-in: enable copywrite integration
git config --global hooks.copywrite false # default: disabled
git config --global hooks.licenceCheck true # opt-in: enable licence header formatting
git config --global hooks.licenceCheck false # default: disabled
```

* **Set Mode (`fix` vs `check`):**
```bash
git config --global hooks.copywriteMode fix # default: automatically inserts/updates headers on commit
git config --global hooks.copywriteMode check # read-only check (warns/fails if headers are missing)
git config --global hooks.licenceCheckMode fix # default: automatically inserts/updates headers on commit
git config --global hooks.licenceCheckMode check # read-only check (warns/fails if headers are missing)
```

## Recommended settings
Expand Down
21 changes: 7 additions & 14 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,23 @@ inputs:
commitMessage:
description: 'The commit message'
required: true
licenceCheck:
description: 'Validate CCDC copyright and licence headers on changed files (true/false)'
required: false
default: 'false'
licenseCheck:
description: 'Validate CCDC copyright and license headers on changed files (true/false)'
description: 'Alias for licenceCheck (true/false)'
required: false
default: 'false'
runs:
using: composite
steps:
- name: Install copywrite
if: ${{ inputs.licenseCheck == 'true' }}
uses: hashicorp/setup-copywrite@v1.1.3

- name: Validate Header Compliance
if: ${{ inputs.licenseCheck == 'true' }}
if: ${{ inputs.licenceCheck == 'true' || inputs.licenseCheck == 'true' }}
shell: bash
env:
COPYWRITE_HOOK_ROOT: ${{ github.action_path }}
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
run: |
copywrite --version

CHANGED_FILES=()
if [ "${GITHUB_EVENT_NAME:-}" = "pull_request" ] && [ -n "${GITHUB_BASE_REF:-}" ]; then
DIFF_REF="origin/${GITHUB_BASE_REF}"
Expand Down Expand Up @@ -82,11 +79,7 @@ runs:

if [ ${#CHANGED_FILES[@]} -gt 0 ]; then
echo "Checking ${#CHANGED_FILES[@]} changed file(s) for header compliance..."
copywrite headers \
--config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" \
--plan \
-- \
"${CHANGED_FILES[@]}"
python3 "$GITHUB_ACTION_PATH/main/licence_headers.py" check -- "${CHANGED_FILES[@]}"
else
echo "No added or modified files found to check for header compliance."
fi
Expand Down
2 changes: 1 addition & 1 deletion main/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ case "$OSTYPE" in
;;
esac

"${PYTHON_EXECUTABLE[@]}" "${BASH_SOURCE[0]%.*}.py" "$@"
"${PYTHON_EXECUTABLE[@]}" "${BASH_SOURCE[0]}.py" "$@"
37 changes: 0 additions & 37 deletions main/copywrite/.copywrite.hcl

This file was deleted.

Loading