-
Notifications
You must be signed in to change notification settings - Fork 1
Sys-8665 copywrite #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ba1948a
SYS-8665 base changes
mmaharjan-ccdc 1fa442c
SYS-8665 improvements and readme updates
mmaharjan-ccdc 14798f7
SYS-8665 minor updates to readme
mmaharjan-ccdc d3b70fb
SYS-8665 add copywrite message at top
mmaharjan-ccdc 8af5d3c
SYS-8665 don't always run for copywrite_fix
mmaharjan-ccdc 777389e
SYS-8665 update action to check for changed files
mmaharjan-ccdc 28f728a
sys-8665 terminate option parsing before repo paths
mmaharjan-ccdc 47b824a
SYS-8665 Add an option terminator before the filenames
mmaharjan-ccdc a7caa82
SYS-8665 update readme for github actions
mmaharjan-ccdc c98566e
SYS-8665 insert how to get copywrite on windows
mmaharjan-ccdc 1c77ab3
SYS-8665 create template files
mmaharjan-ccdc 6d90dd0
SYS-8665 integrate into githooks.py as optional, update readme and re…
mmaharjan-ccdc 1990b3b
SYS-8665 co-pilot comments
mmaharjan-ccdc 481fd2f
SYS-8665 use v8 branch and add unit tests
mmaharjan-ccdc 8a3e0b3
SYS-8665 use setup-python@v7
mmaharjan-ccdc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,104 @@ | ||
| # | ||
| # This code is Copyright (C) 2026 The Cambridge Crystallographic Data Centre (CCDC) | ||
| # of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. This | ||
| # code may not be used, reproduced, translated, modified, disassembled or | ||
| # copied, except in accordance with a valid licence agreement with CCDC and | ||
| # may NOT be disclosed or redistributed in any form, either in whole or in | ||
| # part, to any third party. All copies of this code made in accordance with a | ||
| # valid licence agreement as referred to above must contain this copyright | ||
| # notice. | ||
| # | ||
| # No representations, warranties, or liabilities are expressed or implied in | ||
| # the supply of this code by CCDC, its servants or agents, except where such | ||
| # exclusion or limitation is prohibited, void or unenforceable under governing | ||
| # law. | ||
| # | ||
| name: CCDC File Checks | ||
| author: CCDC | ||
| description: Check changed files for compliance | ||
| inputs: | ||
| commitMessage: | ||
| description: 'The commit message' | ||
| required: true | ||
| licenseCheck: | ||
| description: 'Validate CCDC copyright and license headers on changed files (true/false)' | ||
| required: false | ||
| default: 'false' | ||
| runs: | ||
| using: "composite" | ||
| using: composite | ||
| steps: | ||
| - run: python3 $GITHUB_ACTION_PATH/main.py | ||
| - name: Install copywrite | ||
| if: ${{ inputs.licenseCheck == 'true' }} | ||
| uses: hashicorp/setup-copywrite@v1.1.3 | ||
|
|
||
| - name: Validate Header Compliance | ||
| if: ${{ 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}" | ||
| if ! git rev-parse --verify "$DIFF_REF" >/dev/null 2>&1; then | ||
| DIFF_REF="remotes/origin/${GITHUB_BASE_REF}" | ||
| fi | ||
| if ! git rev-parse --verify "$DIFF_REF" >/dev/null 2>&1; then | ||
| DIFF_REF="${GITHUB_BASE_REF}" | ||
| fi | ||
| if ! git rev-parse --verify "$DIFF_REF" >/dev/null 2>&1; then | ||
| echo "Unable to resolve pull request base ref: ${GITHUB_BASE_REF}" >&2 | ||
| exit 1 | ||
| fi | ||
| while IFS= read -r file; do | ||
| [ -n "$file" ] && CHANGED_FILES+=("$file") | ||
| done < <(git diff --name-only --diff-filter=d "${DIFF_REF}...HEAD") | ||
| elif [ "${GITHUB_EVENT_NAME:-}" = "push" ]; then | ||
| if [[ "${GITHUB_EVENT_BEFORE:-}" =~ ^0+$ ]]; then | ||
| while IFS= read -r file; do | ||
| [ -n "$file" ] && CHANGED_FILES+=("$file") | ||
| done < <(git diff-tree --root --no-commit-id --name-only --diff-filter=d -r HEAD) | ||
| else | ||
| if [ -z "${GITHUB_EVENT_BEFORE:-}" ] || ! git rev-parse --verify "${GITHUB_EVENT_BEFORE}^{commit}" >/dev/null 2>&1; then | ||
| echo "Unable to resolve push baseline: ${GITHUB_EVENT_BEFORE:-<empty>}" >&2 | ||
| exit 1 | ||
| fi | ||
| while IFS= read -r file; do | ||
| [ -n "$file" ] && CHANGED_FILES+=("$file") | ||
| done < <(git diff --name-only --diff-filter=d "${GITHUB_EVENT_BEFORE}..HEAD") | ||
| fi | ||
| elif git rev-parse --verify HEAD^ >/dev/null 2>&1; then | ||
| while IFS= read -r file; do | ||
| [ -n "$file" ] && CHANGED_FILES+=("$file") | ||
| done < <(git diff --name-only --diff-filter=d HEAD^..HEAD) | ||
| else | ||
| while IFS= read -r file; do | ||
| [ -n "$file" ] && CHANGED_FILES+=("$file") | ||
| done < <(git diff-tree --root --no-commit-id --name-only --diff-filter=d -r HEAD) | ||
| fi | ||
|
|
||
| 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[@]}" | ||
|
Copilot marked this conversation as resolved.
|
||
| else | ||
| echo "No added or modified files found to check for header compliance." | ||
| fi | ||
|
|
||
| - name: Run file compliance check | ||
| shell: bash | ||
| env: | ||
| INPUT_COMMITMESSAGE: ${{ inputs.commitMessage }} | ||
| GITHUB_EVENT_BEFORE: ${{ github.event.before }} | ||
| run: | | ||
| python3 "$GITHUB_ACTION_PATH/main.py" | ||
|
|
||
| branding: | ||
| icon: 'check-square' | ||
| color: 'green' | ||
| icon: check-square | ||
| color: green | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| schema_version = 1 | ||
|
|
||
| project { | ||
| copyright_holder = "The Cambridge Crystallographic Data Centre (CCDC)" | ||
|
|
||
| header_ignore = [ | ||
| ".git/**", | ||
| ".github/**", | ||
| "test/**", | ||
| "tests/**", | ||
| "templates/**", | ||
| "**/bin/**", | ||
| "**/obj/**", | ||
| "**/packages/**", | ||
| "**/node_modules/**", | ||
| "**/dist/**", | ||
| "**/build/**", | ||
| "**/.venv/**", | ||
| "**/venv/**", | ||
| "**/__pycache__/**", | ||
| "**/*.Designer.cs", | ||
| "**/*.g.cs", | ||
| "**/*.generated.*", | ||
| "**/*.min.js", | ||
| "**/*.lock", | ||
| ] | ||
| } | ||
|
|
||
| rule { | ||
| paths = ["**/*.py", "**/*.sh", "**/*.bash", "**/*.yaml", "**/*.yml"] | ||
| license_header = "${COPYWRITE_HOOK_ROOT}/main/copywrite/headers/ccdc_hash.tmpl" | ||
| } | ||
|
|
||
| rule { | ||
| paths = ["**/*.js", "**/*.ts", "**/*.cs", "**/*.cpp", "**/*.cxx", "**/*.cc", "**/*.h", "**/*.hpp"] | ||
| license_header = "${COPYWRITE_HOOK_ROOT}/main/copywrite/headers/ccdc_slash.tmpl" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # | ||
| # This code is Copyright (C) {{ .Year }} The Cambridge Crystallographic Data Centre (CCDC) | ||
| # of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. This | ||
| # code may not be used, reproduced, translated, modified, disassembled or | ||
| # copied, except in accordance with a valid licence agreement with CCDC and | ||
| # may NOT be disclosed or redistributed in any form, either in whole or in | ||
|
mmaharjan-ccdc marked this conversation as resolved.
|
||
| # part, to any third party. All copies of this code made in accordance with a | ||
| # valid licence agreement as referred to above must contain this copyright | ||
| # notice. | ||
| # | ||
| # No representations, warranties, or liabilities are expressed or implied in | ||
| # the supply of this code by CCDC, its servants or agents, except where such | ||
| # exclusion or limitation is prohibited, void or unenforceable under governing | ||
| # law. | ||
| # | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // | ||
| // This code is Copyright (C) {{ .Year }} The Cambridge Crystallographic Data Centre (CCDC) | ||
| // of 12 Union Road, Cambridge CB2 1EZ, UK and a proprietary work of CCDC. This | ||
| // code may not be used, reproduced, translated, modified, disassembled or | ||
| // copied, except in accordance with a valid licence agreement with CCDC and | ||
| // may NOT be disclosed or redistributed in any form, either in whole or in | ||
|
mmaharjan-ccdc marked this conversation as resolved.
|
||
| // part, to any third party. All copies of this code made in accordance with a | ||
| // valid licence agreement as referred to above must contain this copyright | ||
| // notice. | ||
| // | ||
| // No representations, warranties, or liabilities are expressed or implied in | ||
| // the supply of this code by CCDC, its servants or agents, except where such | ||
| // exclusion or limitation is prohibited, void or unenforceable under governing | ||
| // law. | ||
| // | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.