Skip to content

Copyright notices: script and pre-commit hook (#13)#19

Merged
blms merged 5 commits intomainfrom
feature/13-copyright-script
May 19, 2025
Merged

Copyright notices: script and pre-commit hook (#13)#19
blms merged 5 commits intomainfrom
feature/13-copyright-script

Conversation

@blms
Copy link
Copy Markdown
Contributor

@blms blms commented May 13, 2025

Associated Issue(s): #13

Changes in this PR

  • Add script that can add a copyright notice to all files missing it, or which only have the Emory notice
  • Allow the --check argument to report on files missing notices (in this mode, will not modify files)
  • Add a pre-commit hook that runs the script with --check on all new/changed files, which will fail if notices are missing
  • Run the script against the entire repo to produce missing copyright notices

Notes

  • I used the SPDX shorthand for adding notices to files that don't have one, does that make sense to you or should we be more consistent and use the old long-form notice?

  • Should I add unit tests for the script?

  • For now the script only supports # style comments in python, yaml, and toml; running against the whole repo with --check shows these additional files missing notices. Let me know if I should address or if it's ok for now.

    Missing copyright report
    The following files are missing a copyright notice:
    - ./CHANGELOG.rst
    - ./DEVNOTES.rst
    - ./MIGRATION.rst
    - ./README.rst
    - ./pytest.ini
    - ./doc/Makefile
    - ./doc/_static/style.css
    - ./doc/build/html/_sources/catalog.rst.txt
    - ./doc/build/html/_sources/changelog.rst.txt
    - ./doc/build/html/_sources/index.rst.txt
    - ./doc/build/html/_sources/xmlmap.rst.txt
    - ./doc/build/html/_sources/xmlmap/cerp.rst.txt
    - ./doc/build/html/_sources/xmlmap/dc.rst.txt
    - ./doc/build/html/_sources/xmlmap/ead.rst.txt
    - ./doc/build/html/_sources/xmlmap/mods.rst.txt
    - ./doc/build/html/_sources/xmlmap/premis.rst.txt
    - ./doc/build/html/_sources/xpath.rst.txt
    - ./doc/build/html/_static/alabaster.css
    - ./doc/build/html/_static/basic.css
    - ./doc/build/html/_static/custom.css
    - ./doc/build/html/_static/doctools.js
    - ./doc/build/html/_static/documentation_options.js
    - ./doc/build/html/_static/github-banner.svg
    - ./doc/build/html/_static/language_data.js
    - ./doc/build/html/_static/pygments.css
    - ./doc/build/html/_static/searchtools.js
    - ./doc/build/html/_static/sphinx_highlight.js
    - ./doc/build/html/_static/style.css
    - ./doc/build/html/catalog.html
    - ./doc/build/html/changelog.html
    - ./doc/build/html/genindex.html
    - ./doc/build/html/index.html
    - ./doc/build/html/py-modindex.html
    - ./doc/build/html/search.html
    - ./doc/build/html/searchindex.js
    - ./doc/build/html/xmlmap.html
    - ./doc/build/html/xmlmap/cerp.html
    - ./doc/build/html/xmlmap/dc.html
    - ./doc/build/html/xmlmap/ead.html
    - ./doc/build/html/xmlmap/mods.html
    - ./doc/build/html/xmlmap/premis.html
    - ./doc/build/html/xpath.html
    - ./doc/catalog.rst
    - ./doc/changelog.rst
    - ./doc/index.rst
    - ./doc/templates/sidebar_footer.html
    - ./doc/xmlmap.rst
    - ./doc/xmlmap/cerp.rst
    - ./doc/xmlmap/dc.rst
    - ./doc/xmlmap/ead.rst
    - ./doc/xmlmap/mods.rst
    - ./doc/xmlmap/premis.rst
    - ./doc/xpath.rst
    

@blms blms requested a review from rlskoeser May 13, 2025 19:15
@blms blms changed the title Copyright notices, script, pre-commit hook (#13) Copyright notices: script and pre-commit hook (#13) May 13, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.21%. Comparing base (2784104) to head (ebc128b).
Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #19   +/-   ##
=======================================
  Coverage   85.21%   85.21%           
=======================================
  Files          15       15           
  Lines        2165     2165           
=======================================
  Hits         1845     1845           
  Misses        320      320           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rlskoeser
Copy link
Copy Markdown
Contributor

  • I used the SPDX shorthand for adding notices to files that don't have one, does that make sense to you or should we be more consistent and use the old long-form notice?

It feels weird to be inconsistent, but I also don't love the long-form notice. I think let's leave it.

Would it be possible to add (eulxml) to the end of the original Emory copyright notice? Just be a one-time change, not part of the script.

  • Should I add unit tests for the script?

I think let's not bother - it's a utility script, not part of the library itself.

Let's exempt github workflows from the copyright - those are mostly borrowed from other projects or examples anyway.

Copy link
Copy Markdown
Contributor

@rlskoeser rlskoeser left a comment

Choose a reason for hiding this comment

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

I pulled this branch and installed the pre-commit hooks, and then ran with pre-commit run --all.

It reports that check-copyright fails because of the files that don't have a copyright notice.

Will this cause any problems when committing changes to those files?

That's my only concern, I think other than making sure that's not a problem this is good to merge.

@blms
Copy link
Copy Markdown
Contributor Author

blms commented May 19, 2025

@rlskoeser Thanks for testing locally!

Good point. Since our script can't check for those files' comment syntax, it will never pass for them. So we should either exempt them from the script, or add their comment syntax to the checkable types so that it will actually pass once someone adds a copyright notice to them.

@rlskoeser
Copy link
Copy Markdown
Contributor

Good point. Since our script can't check for those files' comment syntax, it will never pass for them. So we should either exempt them from the script, or add their comment syntax to the checkable types so that it will actually pass once someone adds a copyright notice to them.

@blms for now can you exempt them by using the file pattern option in the pre-commit hook, so we only check the files where failure means it should not be committed?

@blms blms force-pushed the feature/13-copyright-script branch from 8bd6dba to ebc128b Compare May 19, 2025 18:07
@blms blms requested a review from rlskoeser May 19, 2025 18:15
Copy link
Copy Markdown
Contributor

@rlskoeser rlskoeser left a comment

Choose a reason for hiding this comment

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

Ran the updated pre-commit check and no failures.

Also ran the script directly a few times to see - seems fine for what we need.

@blms blms merged commit 992ff81 into main May 19, 2025
10 checks passed
@blms blms deleted the feature/13-copyright-script branch May 19, 2025 18:39
@blms blms mentioned this pull request May 19, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants