Skip to content

fix(PLA-3414): copyrigth text check - #40

Open
shanooni024 wants to merge 6 commits into
ccdc-opensource:mainfrom
shanooni024:PLA-3414-license-text-hook
Open

fix(PLA-3414): copyrigth text check#40
shanooni024 wants to merge 6 commits into
ccdc-opensource:mainfrom
shanooni024:PLA-3414-license-text-hook

Conversation

@shanooni024

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds copyright-header validation and remediation using HashiCorp Copywrite.

Changes:

  • Adds Copywrite configuration and CCDC header templates.
  • Adds check and fix shell hooks.
  • Integrates header validation into the composite action.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
action.yml Installs and runs Copywrite.
.pre-commit-hook.yaml Registers check and fix hooks.
main/hooks/copywrite_check.sh Checks header compliance.
main/hooks/copywrite_fix.sh Applies compliant headers.
main/copywrite/.copywrite.hcl Defines header rules and exclusions.
main/copywrite/headers/ccdc_hash.tmpl Adds hash-comment header template.
main/copywrite/headers/ccdc_slash.tmpl Adds slash-comment header template.
Suppressed comments (1)

.pre-commit-hook.yaml:9

  • This entry points to a nonexistent root-level script; the added fixer is under main/hooks. The manual hook will therefore fail to start.
  entry: hooks/copywrite_fix.sh

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .pre-commit-hooks.yaml
Comment thread .pre-commit-hook.yaml Outdated
Comment thread main/copywrite/.copywrite.hcl Outdated
Comment thread action.yml
Comment thread main/hooks/copywrite_check.sh Outdated
Comment thread main/hooks/copywrite_fix.sh Outdated
Comment thread action.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

action.yml:15

  • This makes only the config path action-relative; the config still names both templates as relative main/copywrite/headers/... paths. Composite action commands run in the caller's workspace, so external consumers do not have those paths and header validation fails while loading the templates (the self-test masks this because its workspace is this repository). Make the template paths resolve from $GITHUB_ACTION_PATH without changing the workspace that Copywrite scans.
      run: copywrite headers --config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" --plan

Comment thread main/hooks/copywrite_check.sh Outdated
Comment thread main/hooks/copywrite_fix.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

action.yml:15

  • This invokes Copywrite without restricting it to the commit's files, so it validates the entire checkout. That breaks the composite action's documented changed-file scope (action.yml:3 and main.py:23-40) and can reject a PR because of an untouched historical file. Limit header validation to the modified/added files selected by get_commit_files, or expose repository-wide validation as an explicitly documented opt-in.
      run: copywrite headers --config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" --plan

Comment thread main/hooks/copywrite_fix.sh Outdated
Comment thread main/hooks/copywrite_check.sh Outdated
Comment thread main/copywrite/.copywrite.hcl Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Suppressed comments (2)

main/hooks/copywrite_check.sh:4

  • This path is resolved from main/hooks, so it points to the nonexistent main/hooks/main/copywrite/.copywrite.hcl. The check hook exits before checking any headers; reference the sibling copywrite directory instead.
copywrite headers --config="$(dirname "${BASH_SOURCE[0]}")/main/copywrite/.copywrite.hcl" --plan

main/hooks/copywrite_fix.sh:4

  • This path is resolved from main/hooks, so it points to the nonexistent main/hooks/main/copywrite/.copywrite.hcl. The manual fix hook therefore cannot run; reference the sibling copywrite directory instead.
copywrite headers --config="$(dirname "${BASH_SOURCE[0]}")/main/copywrite/.copywrite.hcl"

Comment thread .pre-commit-hooks.yaml Outdated
Comment thread action.yml

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Suppressed comments (3)

Previously missed (1) — in code that hasn't changed since the last review.

main/copywrite/headers/ccdc_slash.tmpl:6

  • This proprietary-use restriction, also duplicated in the hash template and added headers, directly contradicts the repository's MIT LICENSE, which permits copying, modification, and redistribution. Resolve the licensing intent before enforcing the header; if the repository remains MIT, use an MIT-compatible copyright header throughout.
// 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

action.yml:29

  • This invocation does not set COPYWRITE_HOOK_ROOT, although both license_header values interpolate it. Only the two wrapper scripts export that variable, so the composite-action path cannot resolve its templates and the new validation step fails. Set it for this command.
      run: copywrite headers --config "$GITHUB_ACTION_PATH/main/copywrite/.copywrite.hcl" --plan

.pre-commit-hooks.yaml:30

  • The manual hook repeats the invalid Python dependency setup: pre-commit passes copywrite==1.1.3 to pip rather than installing the HashiCorp Go CLI, so this hook cannot provision the copywrite command either. Switch it to the same supported CLI installation strategy as the check hook.
  language: python
  pass_filenames: false
  stages: [manual]
  additional_dependencies: 
  - copywrite==1.1.3

Comment thread .pre-commit-hooks.yaml
Comment on lines +18 to +21
language: python
pass_filenames: false
additional_dependencies:
- copywrite==1.1.3
}

rule {
paths = ["**/*.py", "**/*.sh", "**/*.bash", "**/*.yaml", "**/*.yml"]
Comment on lines +1 to +2
# START_LICENSE_TEXT
# This code is Copyright (C) {{ .Year }} The Cambridge Crystallographic Data Centre (CCDC)
Comment thread .pre-commit-hooks.yaml
@@ -0,0 +1,30 @@
#
# This code is Copyright (C) <year> The Cambridge Crystallographic Data Centre
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants