Skip to content

SYS-8665 fix changed files - #42

Merged
mmaharjan-ccdc merged 21 commits into
mainfrom
SYS-8665-copywrite
Aug 31, 2026
Merged

SYS-8665 fix changed files#42
mmaharjan-ccdc merged 21 commits into
mainfrom
SYS-8665-copywrite

Conversation

@mmaharjan-ccdc

Copy link
Copy Markdown
Contributor

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

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, offset equals 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.

Comment thread main/license_headers.py Outdated
Comment thread main/license_headers.py 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 10 out of 10 changed files in this pull request and generated 3 comments.

Comment thread main/license_headers.py Outdated
Comment thread main/license_headers.py Outdated
Comment thread main/license_headers.py

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 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-status output is tab-delimited, but the existing whitespace split drops any staged file whose path contains spaces: for M\tpath/my file.py, parts[-2] is not M. 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

Comment thread main/licence_headers.py Outdated
Comment thread main/licence_headers.py 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 12 out of 13 changed files in this pull request and generated 4 comments.

Comment thread main/githooks.py
Comment thread main/githooks.py Outdated
Comment thread main/githooks.py
Comment thread main/licence_headers.py 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 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.copywrite and hooks.copywriteMode settings 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 for licenseCheck.
    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_files reads 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,

Comment thread main/licence_headers.py Outdated
@mmaharjan-ccdc
mmaharjan-ccdc merged commit 3458b04 into main Aug 31, 2026
6 checks passed
@mmaharjan-ccdc
mmaharjan-ccdc deleted the SYS-8665-copywrite branch August 31, 2026 15:33
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.

3 participants