Process 1 build 0203261953
This commit is contained in:
45
scripts/render_git_changelog.py
Normal file
45
scripts/render_git_changelog.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def build_git_changelog(repo_root: Path, max_count: int) -> str:
|
||||
result = subprocess.run(
|
||||
[
|
||||
"git",
|
||||
"log",
|
||||
f"--max-count={max_count}",
|
||||
"--date=short",
|
||||
"--pretty=format:%cs|%s",
|
||||
"--",
|
||||
".",
|
||||
],
|
||||
cwd=repo_root,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
lines = [line.strip() for line in result.stdout.splitlines() if line.strip()]
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--max-count", type=int, default=200)
|
||||
parser.add_argument("--python-literal", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
repo_root = Path(__file__).resolve().parents[1]
|
||||
changelog = build_git_changelog(repo_root, max_count=args.max_count)
|
||||
if args.python_literal:
|
||||
print(repr(changelog))
|
||||
else:
|
||||
sys.stdout.write(changelog)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user