deb-mock/releng/generate-release-notes
robojerk 4c0dcb2522
Some checks failed
Build Deb-Mock Package / build (push) Successful in 54s
Lint Code / Lint All Code (push) Failing after 1s
Test Deb-Mock Build / test (push) Failing after 36s
enhance: Add comprehensive .gitignore for deb-mock project
- Add mock-specific build artifacts (chroot/, mock-*, mockroot/)
- Include package build files (*.deb, *.changes, *.buildinfo)
- Add development tools (.coverage, .pytest_cache, .tox)
- Include system files (.DS_Store, Thumbs.db, ._*)
- Add temporary and backup files (*.tmp, *.bak, *.backup)
- Include local configuration overrides (config.local.yaml, .env.local)
- Add test artifacts and documentation builds
- Comprehensive coverage for Python build system project

This ensures build artifacts, chroot environments, and development
tools are properly ignored in version control.
2025-08-18 23:37:49 -07:00

115 lines
3.5 KiB
Python
Executable file

#! /usr/bin/python3
import argparse
import os
import re
import subprocess
import tempfile
TRANSFORM = {
"rhbz": "https://bugzilla.redhat.com/{id}",
"issue": "https://github.com/rpm-software-management/mock/issues/{id}",
"PR": "https://github.com/rpm-software-management/mock/pull/{id}",
"commit": "https://github.com/rpm-software-management/mock/commit/{id}",
"copr_issue": "https://github.com/fedora-copr/copr/issues/{id}",
}
TEMP_FILE = ".Release-Notes-Next.md"
def _arg_parser():
parser = argparse.ArgumentParser()
parser.add_argument("--use-version", dest="version")
group = parser.add_mutually_exclusive_group()
group.add_argument("--config-only", action="store_true")
group.add_argument("--mock-only", action="store_true")
return parser
def _limited_config(opts):
if not opts.config_only and not opts.mock_only:
return []
with tempfile.NamedTemporaryFile(delete=False, dir=".") as config_fd:
opts.temp_config = config_fd.name
with open("pyproject.toml", "rb") as fd:
for line in fd.readlines():
if b'{ name' not in line:
config_fd.write(line)
continue
# skip non-config files
if opts.config_only and b"config" not in line:
continue
# skip config files
if opts.mock_only and b"config" in line:
continue
config_fd.write(line)
return ["--config", opts.temp_config]
def _main():
options = _arg_parser().parse_args()
options.temp_config = None
tc_opts = _limited_config(options)
if not options.version:
options.version = "Next"
tc_opts.append("--keep")
else:
tc_opts.append("--yes")
output_file = os.path.join(f"docs/Release-Notes-{options.version}.md")
found = set()
pattern = "|".join(TRANSFORM.keys())
issues_re = re.compile(r"\[(" + pattern + r")#([0-9a-f]+)\]")
cmd = ["towncrier", "build", "--version", options.version] + tc_opts
print(f"Calling {cmd}")
subprocess.check_call(cmd)
with open(output_file, "w", encoding="utf8") as fdout:
fdout.write(f"""---
layout: default
title: Release Notes - Mock {options.version}
---
""")
if options.version == "Next":
fdout.write("""\
# Pre-release Mock changelog
Every change in Mock or `mock-core-configs` that deserves some promotion needs
to be mentioned in release notes. This generated page provides a set of changes
that will land the future version of Mock. See [how to add
entries](Release-Notes-New-Entry).
""")
with open(TEMP_FILE, encoding="utf8") as fdorig:
for line in fdorig:
fdout.write(line)
findings = re.findall(issues_re, line)
if not findings:
continue
for finding in findings:
found.add(finding)
fdout.write("\n")
for (key, value) in found:
fdout.write(f"[{key}#{value}]: {TRANSFORM[key].format(id=value)}\n")
if options.version != "Next":
subprocess.check_call(["git", "add", output_file])
if __name__ == "__main__":
# go top-level
os.chdir(os.path.join(os.path.dirname(__file__), '..'))
try:
_main()
finally:
try:
os.unlink(TEMP_FILE)
subprocess.check_call(["git", "rm", "-f", TEMP_FILE])
except FileNotFoundError:
pass