MCPcopy
hub / github.com/pytest-dev/pytest / announce

Function announce

scripts/release.py:18–76  ·  view source on GitHub ↗

Generates a new release announcement entry in the docs.

(version: str, template_name: str, doc_version: str)

Source from the content-addressed store, hash-verified

16
17
18def announce(version: str, template_name: str, doc_version: str) -> None:
19 """Generates a new release announcement entry in the docs."""
20 # Get our list of authors and co-authors.
21 stdout = check_output(["git", "describe", "--abbrev=0", "--tags"], encoding="UTF-8")
22 last_version = stdout.strip()
23 rev_range = f"{last_version}..HEAD"
24
25 authors = check_output(
26 ["git", "log", rev_range, "--format=%aN"], encoding="UTF-8"
27 ).splitlines()
28
29 co_authors_output = check_output(
30 ["git", "log", rev_range, "--format=%(trailers:key=Co-authored-by) "],
31 encoding="UTF-8",
32 )
33 co_authors: list[str] = []
34 for co_author_line in co_authors_output.splitlines():
35 if m := re.search(r"Co-authored-by: (.+?)<", co_author_line):
36 co_authors.append(m.group(1).strip())
37
38 contributors = {
39 name
40 for name in authors + co_authors
41 if not name.endswith("[bot]") and name != "pytest bot"
42 }
43
44 template_text = (
45 Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
46 )
47
48 contributors_text = "\n".join(f"* {name}" for name in sorted(contributors)) + "\n"
49 text = template_text.format(
50 version=version, contributors=contributors_text, doc_version=doc_version
51 )
52
53 target = Path(__file__).parent.joinpath(f"../doc/en/announce/release-{version}.rst")
54 target.write_text(text, encoding="UTF-8")
55 print(f"{Fore.CYAN}[generate.announce] {Fore.RESET}Generated {target.name}")
56
57 # Update index with the new release entry
58 index_path = Path(__file__).parent.joinpath("../doc/en/announce/index.rst")
59 lines = index_path.read_text(encoding="UTF-8").splitlines()
60 indent = " "
61 for index, line in enumerate(lines):
62 if line.startswith(f"{indent}release-"):
63 new_line = indent + target.stem
64 if line != new_line:
65 lines.insert(index, new_line)
66 index_path.write_text("\n".join(lines) + "\n", encoding="UTF-8")
67 print(
68 f"{Fore.CYAN}[generate.announce] {Fore.RESET}Updated {index_path.name}"
69 )
70 else:
71 print(
72 f"{Fore.CYAN}[generate.announce] {Fore.RESET}Skip {index_path.name} (already contains release)"
73 )
74 break
75

Callers 1

pre_releaseFunction · 0.85

Calls 10

check_callFunction · 0.85
stripMethod · 0.80
appendMethod · 0.80
groupMethod · 0.80
endswithMethod · 0.80
read_textMethod · 0.80
joinMethod · 0.80
write_textMethod · 0.80
insertMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…