Repository navigation
chore(docs): keep internal references out of docs and commit messages (LAB-8003) #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
aa4d406
chore: keep internal references out of docs and commit messages
27Bslash6 cee01d1
chore: narrow the cluster pattern, skip merge subjects, cover crate R…
27Bslash6 25348ed
chore: read commit messages only above the scissors line, widen the k…
27Bslash6 8984ed9
chore: one commit-message check that ignores the verbose diff and git…
27Bslash6 72b98f6
chore: treat only git's own comment lines as comments in the commit-m…
27Bslash6 b01ef22
chore: cover every merge subject git writes, and report an unreadable…
27Bslash6 cebb2c5
chore: accept semicolon-joined merge subjects and the underscore form…
27Bslash6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Pre-commit hooks. Install once per clone: prek install (Python pre-commit works too). | ||
| default_install_hook_types: [pre-commit, commit-msg] | ||
|
|
||
| repos: | ||
| # Keeps internal references (ticket ids, secret-store paths, internal hosts and process | ||
| # names) out of user-facing docs and commit messages. The patterns are generic on purpose: | ||
| # a list of specific internal names would itself disclose them. | ||
| # Scope rule: https://docs.cachekit.io/contributing/#what-belongs-in-these-docs | ||
| - repo: local | ||
| hooks: | ||
| - id: no-internal-references | ||
| name: No internal references in docs | ||
| language: pygrep | ||
| entry: '\b(?i:LAB)-[0-9]+|op://|\.ts\.net|(?i:\bk3s[\s_-]+(?:cluster|node|host)s?\b)|dev\.cachekit\.io|\bStage [0-9]|\bAC-[0-9]|github\.com/cachekit(?![\w-])' | ||
| files: ^((packages|crates)/[^/]+/)?README[^/]*$|^docs/ | ||
| types: [text] | ||
| stages: [pre-commit] | ||
| - id: no-internal-references-commit-msg | ||
| name: No internal references in commit message | ||
| # Same patterns. git hands this hook the raw message file: "# " comment lines, the diff | ||
| # below the `git commit -v` scissors line, and its own merge and revert subjects, which | ||
| # quote branch names and earlier subjects. Only the text the author wrote is checked. | ||
| language: python | ||
| entry: python -c | ||
| args: | ||
| - | | ||
| import re, sys | ||
| P = re.compile(r"\b(?i:LAB)-[0-9]+|op://|\.ts\.net|(?i:\bk3s[\s_-]+(?:cluster|node|host)s?\b)|dev\.cachekit\.io|\bStage [0-9]|\bAC-[0-9]|github\.com/cachekit(?![\w-])") | ||
| KIND = r"(?:branch|branches|remote-tracking branch|remote-tracking branches|tag|tags|commit|commits)" | ||
| GIT_SUBJECT = re.compile(rf"Merge {KIND} '[^']*'(?:(?:, |; | and ){KIND}? ?'[^']*')*(?: of \S+)?(?: into \S+)?|(?:Revert|Reapply) \".*\"") | ||
| try: | ||
| with open(sys.argv[1], encoding="utf-8", errors="replace") as f: | ||
| text = f.read() | ||
| except OSError as e: | ||
| sys.exit(f"{sys.argv[1]}: cannot read the commit message: {e}") | ||
| text = text.split("# ------------------------ >8 ------------------------")[0] | ||
| lines = [line for line in text.splitlines() if line.strip() and not re.match(r"#(?:[ \t]|$)", line)] | ||
| if lines and GIT_SUBJECT.fullmatch(lines[0]): | ||
| lines = lines[1:] | ||
| bad = [line for line in lines if P.search(line)] | ||
| for line in bad: | ||
| print(f"{sys.argv[1]}: {line}") | ||
| sys.exit(1 if bad else 0) | ||
| stages: [commit-msg] | ||
|
kodus-27b[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.