-
Notifications
You must be signed in to change notification settings - Fork 7
Reconcile enterprise/cloud doc divergence + add bump-last-updated tooling #1547
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
Open
justinegeffen
wants to merge
35
commits into
master
Choose a base branch
from
enterprise-cloud-divergence-audit
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
bcc7cf6
Reconcile enterprise/cloud doc divergence + add bump-last-updated too…
justinegeffen 08ba49d
[automated] Fix code formatting
197a870
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 5555c16
Update platform-enterprise_docs/pipelines/versioning.md
justinegeffen 4c77658
Update platform-enterprise_docs/secrets/overview.md
justinegeffen a22a275
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 0c4aa11
[automated] Fix code formatting
996a93b
Switch bump-last-updated to checker pattern with invocable fix command
justinegeffen 3c19717
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen b222e26
[automated] Fix code formatting
ebc1b01
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 893eb61
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 339c264
[automated] Fix code formatting
58e9989
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 3c09ebb
[automated] Fix code formatting
995eb4e
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 0d1dbc0
[automated] Fix code formatting
6b624b1
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen f1d55b9
[automated] Fix code formatting
770b0c0
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen c43dc31
[automated] Fix code formatting
fbb3492
[automated] Fix code formatting
3932901
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 708063c
[automated] Fix code formatting
516e913
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 71117e9
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 2b7ee9b
[automated] Fix code formatting
89536a1
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 11f1c1c
fix: bump stale last updated dates in 3 files after master merge
Copilot a370e98
Merge branch 'master' into enterprise-cloud-divergence-audit
Copilot 466e886
Merge branch 'master' into enterprise-cloud-divergence-audit
Copilot 866a4f0
[automated] Fix code formatting
fb10433
Merge remote-tracking branch 'origin/master' into enterprise-cloud-di…
Copilot 616df9e
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen 9efc0c7
Merge branch 'master' into enterprise-cloud-divergence-audit
justinegeffen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
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,87 @@ | ||
| #!/usr/bin/env python3 | ||
| """Bump frontmatter `last updated:` to today on changed Markdown files. | ||
|
|
||
| Used by the `bump-last-updated` pre-commit / prek hook. Pre-commit passes | ||
| each changed `.md` / `.mdx` file path as a positional argument. For each: | ||
|
|
||
| - If frontmatter has `last updated:`, set its value to today (YYYY-MM-DD). | ||
| - If frontmatter has `date created:` but no `last updated:`, insert | ||
| `last updated:` immediately after `date created:` with today's date. | ||
| - Files without a `date created:` field are skipped — they don't follow | ||
| the convention this hook enforces. | ||
|
|
||
| Standard pre-commit fixer convention: exits non-zero if any file was | ||
| modified so pre-commit re-stages and re-runs. Exits zero on a no-op. | ||
| """ | ||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| import sys | ||
| from datetime import date | ||
| from pathlib import Path | ||
|
|
||
| TODAY = date.today().strftime("%Y-%m-%d") | ||
|
|
||
| FRONTMATTER_RE = re.compile(r"^---[ \t]*\n(.*?\n)---[ \t]*\n", re.DOTALL) | ||
| LAST_UPDATED_RE = re.compile(r"^(last updated:\s*).*$", re.MULTILINE) | ||
| DATE_CREATED_LINE_RE = re.compile(r"^date created:\s*") | ||
|
|
||
|
|
||
| def process(path: Path) -> bool: | ||
| """Bump `last updated:` to today. Return True if file was modified.""" | ||
| try: | ||
| content = path.read_text(encoding="utf-8") | ||
| except (OSError, UnicodeDecodeError): | ||
| return False | ||
|
|
||
| m = FRONTMATTER_RE.match(content) | ||
| if not m: | ||
| return False | ||
| fm = m.group(1) | ||
| rest = content[m.end():] | ||
|
|
||
| # Skip files that don't declare `date created:` — they're outside the | ||
| # convention this hook owns (changelog entries, partials, etc.). | ||
| if not any(DATE_CREATED_LINE_RE.match(line) for line in fm.splitlines()): | ||
| return False | ||
|
|
||
| if LAST_UPDATED_RE.search(fm): | ||
| new_fm = LAST_UPDATED_RE.sub(rf'\1"{TODAY}"', fm, count=1) | ||
| else: | ||
| # Insert `last updated:` right after the `date created:` line. | ||
| out = [] | ||
| inserted = False | ||
| for line in fm.splitlines(): | ||
| out.append(line) | ||
| if not inserted and DATE_CREATED_LINE_RE.match(line): | ||
| out.append(f'last updated: "{TODAY}"') | ||
| inserted = True | ||
| new_fm = "\n".join(out) + "\n" | ||
|
|
||
| if new_fm == fm: | ||
| return False | ||
|
|
||
| path.write_text(f"---\n{new_fm}---\n{rest}", encoding="utf-8") | ||
| return True | ||
|
|
||
|
|
||
| def main(argv: list[str]) -> int: | ||
| modified: list[str] = [] | ||
| for arg in argv: | ||
| p = Path(arg) | ||
| if not p.is_file() or p.suffix not in (".md", ".mdx"): | ||
| continue | ||
| if process(p): | ||
| modified.append(str(p)) | ||
|
|
||
| if modified: | ||
| print(f"Bumped `last updated:` to {TODAY} in:") | ||
| for f in modified: | ||
| print(f" {f}") | ||
| # Non-zero exit signals pre-commit to re-stage and re-run. | ||
| return 1 | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main(sys.argv[1:])) | ||
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
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
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.
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.