MCPcopy Create free account
hub / github.com/pytest-dev/pytest / announce

Function announce

scripts/release.py:13–61  ·  view source on GitHub ↗

Generates a new release announcement entry in the docs.

(version, template_name, doc_version)

Source from the content-addressed store, hash-verified

11
12
13def announce(version, template_name, doc_version):
14 """Generates a new release announcement entry in the docs."""
15 # Get our list of authors
16 stdout = check_output(["git", "describe", "--abbrev=0", "--tags"])
17 stdout = stdout.decode("utf-8")
18 last_version = stdout.strip()
19
20 stdout = check_output(["git", "log", f"{last_version}..HEAD", "--format=%aN"])
21 stdout = stdout.decode("utf-8")
22
23 contributors = {
24 name
25 for name in stdout.splitlines()
26 if not name.endswith("[bot]") and name != "pytest bot"
27 }
28
29 template_text = (
30 Path(__file__).parent.joinpath(template_name).read_text(encoding="UTF-8")
31 )
32
33 contributors_text = "\n".join(f"* {name}" for name in sorted(contributors)) + "\n"
34 text = template_text.format(
35 version=version, contributors=contributors_text, doc_version=doc_version
36 )
37
38 target = Path(__file__).parent.joinpath(f"../doc/en/announce/release-{version}.rst")
39 target.write_text(text, encoding="UTF-8")
40 print(f"{Fore.CYAN}[generate.announce] {Fore.RESET}Generated {target.name}")
41
42 # Update index with the new release entry
43 index_path = Path(__file__).parent.joinpath("../doc/en/announce/index.rst")
44 lines = index_path.read_text(encoding="UTF-8").splitlines()
45 indent = " "
46 for index, line in enumerate(lines):
47 if line.startswith(f"{indent}release-"):
48 new_line = indent + target.stem
49 if line != new_line:
50 lines.insert(index, new_line)
51 index_path.write_text("\n".join(lines) + "\n", encoding="UTF-8")
52 print(
53 f"{Fore.CYAN}[generate.announce] {Fore.RESET}Updated {index_path.name}"
54 )
55 else:
56 print(
57 f"{Fore.CYAN}[generate.announce] {Fore.RESET}Skip {index_path.name} (already contains release)"
58 )
59 break
60
61 check_call(["git", "add", str(target)])
62
63
64def regen(version):

Callers 1

pre_releaseFunction · 0.85

Calls 4

check_callFunction · 0.85
stripMethod · 0.80
insertMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected