Add dependabot, devcontainer and make cr-checker usable via pre-commit hooks#117
Conversation
b969a24 to
40657f5
Compare
40657f5 to
f84bd2e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [rs] | ||
| // ******************************************************************************* | ||
| // Copyright (c) {year} Contributors to the Eclipse Foundation | ||
| // Copyright (c) {year} {author} |
There was a problem hiding this comment.
Changing the Rust header template to use {author} makes has_copyright() treat the author portion as a wildcard (it formats {author} as .* when building the regex), so Rust files with any author string will now be considered compliant. If the intent is to enforce a specific author (e.g., from config.json), keep the literal author in the template or update has_copyright() to substitute the configured author instead of .*.
| // Copyright (c) {year} {author} | |
| // Copyright (c) {year} Contributors to the Eclipse Foundation |
There was a problem hiding this comment.
the other templates are done the same way
| if offset > 0 and offset != byte_array: | ||
| LOGGER.error("Invalid offset value: %d, expected: %d", offset, byte_array) | ||
| LOGGER.error( | ||
| "%s: Invalid offset value: %d, expected: %d", path, offset, byte_array | ||
| ) | ||
| return False |
There was a problem hiding this comment.
fix_copyright rejects offsets that include trailing newline(s) after a shebang because it requires offset == len(first_line) (byte length of only the first line). But detect_shebang_offset() explicitly counts trailing \n/\r, so process_files(..., --fix) will fail to fix files whose shebang line is followed by blank line(s). Consider preserving exactly offset bytes (read/write that prefix) or relaxing the validation to accept offsets greater than the first-line byte length and preserve those extra newline bytes as well.
There was a problem hiding this comment.
might pick this up in future work. At the moment the logging shall help in finding files, which make it fail for manual fixes.
| entry: cr_checker/tool/pre-commit_wrapper --extensions h hpp c cpp rs rst py sh bzl ini yml yaml BUILD bazel --fix | ||
| # this would be the better language implementation, but struggle with python tooling | ||
| # language: python | ||
| language: unsupported_script |
There was a problem hiding this comment.
language: unsupported_script is not a valid pre-commit hook language (pre-commit supports e.g. script, system, python, etc.). This will cause pre-commit to fail loading the hook manifest/config. Use language: script (if pre-commit_wrapper is executable) or language: system with an explicit python3 ... entry.
| language: unsupported_script | |
| language: script |
There was a problem hiding this comment.
script is the same, but obsolete language: https://pre-commit.com/#unsupported_script
| entry: cr_checker/tool/pre-commit_wrapper --extensions h hpp c cpp rs rst py sh bzl ini yml yaml BUILD bazel --fix | ||
| # this would be the better language implementation, but struggle with python tooling | ||
| # language: python | ||
| language: unsupported_script |
There was a problem hiding this comment.
language: unsupported_script is not a valid pre-commit hook language, so the local hook configuration will error when running pre-commit install / pre-commit run. Switch to language: script (if the wrapper is executable) or language: system and invoke python3 explicitly in entry.
| language: unsupported_script | |
| language: script |
There was a problem hiding this comment.
script is the same, but obsolete language: https://pre-commit.com/#unsupported_script
This is a collection of improvements among these the pre-commit-hook.yaml is the one I care most. It allows to check copyright headers without bazel. The solution is not yet perfect, but works good enough for a simple python script.
The other stuff (dependabot, devcontainer) is convenience and automation.