SYS-8665 fix changed files - #42
Conversation
There was a problem hiding this comment.
Pull request overview
Replaces the external Copywrite dependency with native Python licence-header validation and repair.
Changes:
- Adds native header checking/fixing with tests.
- Updates hooks and GitHub Action integration.
- Corrects staged-file detection and hook script paths.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
main/license_headers.py |
Implements header validation and repair. |
test/test_license_headers.py |
Tests licence-header behavior. |
main/githooks.py |
Integrates the native implementation and updates staged diffs. |
action.yml |
Runs native header validation. |
main/copywrite/.copywrite.hcl |
Removes obsolete Copywrite configuration. |
main/pre-commit |
Corrects Python entry-point path. |
main/pre-merge-commit |
Corrects Python entry-point path. |
main/commit-msg |
Corrects Python entry-point path. |
.github/workflows/quality_check.yml |
Adds the new tests to CI. |
README.md |
Documents native licence-header configuration. |
Suppressed comments (1)
main/license_headers.py:129
- If a shebang or encoding declaration is the entire file and has no terminating newline,
offsetequals the text length and this concatenation produces#!/...#\n...(or joins the declaration directly to the header). Insert a separator when the preserved prefix does not already end in a newline.
fixed = text[:offset] + expected + text[header_end:]
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
main/githooks.py:219
- The new
--name-statusoutput is tab-delimited, but the existing whitespace split drops any staged file whose path contains spaces: forM\tpath/my file.py,parts[-2]is notM. Such files are omitted from every pre-commit check. Parse the status separately from the full path instead.
commands = ['git', 'diff', '--cached', '--ignore-submodules', '--name-status', '--']
main/license_headers.py:159
- This scan continues through arbitrary source lines while looking for a later comment ending in
law.. For a truncated/damaged header followed by code and then such a comment, fix mode treats the code as part of the header and deletes it. Stop damaged-header recognition at the first non-comment, nonblank line so the fixer cannot consume source code.
for index, (_, line_end, stripped) in enumerate(line_positions[2:], start=2):
if stripped.startswith(marker) and stripped.endswith('law.'):
if index + 1 < len(line_positions) and line_positions[index + 1][2] == marker:
return line_positions[index + 1][1]
return line_end
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 15 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
main/githooks.py:1085
- The previously documented
hooks.copywriteandhooks.copywriteModesettings are no longer read, so existing installations silently disable header enforcement after upgrading (or unexpectedly switch a configured check-only hook to fix mode). Preserve these settings as fallback aliases, as the Action input already does forlicenseCheck.
enabled_setting = get_config_setting('hooks.licenceCheck')
if enabled_setting is None or enabled_setting.lower() not in ['true', '1', 'yes', 'on']:
return 0
mode = (get_config_setting('hooks.licenceCheckMode') or 'fix').lower()
main/githooks.py:1106
- Check mode permits partially staged files but
process_filesreads their working-tree contents, not the staged blobs that will be committed. An unstaged header can therefore make a staged headerless file pass. Either reject unstaged changes in check mode too or validate content directly from the index.
try:
if not is_check_mode:
unstaged = subprocess.run(
['git', 'diff', '--quiet', '--'] + files,
No description provided.