MCPcopy
hub / github.com/pydantic/pydantic / get_notes

Function get_notes

release/prepare.py:56–97  ·  view source on GitHub ↗

Fetch auto-generated release notes from github.

(new_version: str)

Source from the content-addressed store, hash-verified

54
55
56def get_notes(new_version: str) -> str:
57 """Fetch auto-generated release notes from github."""
58 last_tag = run_command('git', 'describe', '--tags', '--abbrev=0')
59 auth_token = GITHUB_TOKEN
60
61 data = {'target_committish': 'main', 'previous_tag_name': last_tag, 'tag_name': f'v{new_version}'}
62 response = requests.post(
63 f'https://api.github.com/repos/{REPO}/releases/generate-notes',
64 headers={
65 'Accept': 'application/vnd.github+json',
66 'Authorization': f'Bearer {auth_token}',
67 'x-github-api-version': '2022-11-28',
68 },
69 data=json.dumps(data),
70 timeout=100,
71 )
72 response.raise_for_status()
73
74 body = response.json()['body']
75 body = body.replace('<!-- Release notes generated using configuration in .github/release.yml at main -->\n\n', '')
76
77 # Add one level to all headers so they match HISTORY.md, and add trailing newline
78 body = re.sub(pattern='^(#+ .+?)$', repl=r'#\1\n', string=body, flags=re.MULTILINE)
79
80 # Ensure a blank line before headers
81 body = re.sub(pattern='([^\n])(\n#+ .+?\n)', repl=r'\1\n\2', string=body)
82
83 # Render PR links nicely
84 body = re.sub(
85 pattern=f'https://github.com/{REPO}/pull/(\\d+)',
86 repl=f'[#\\1](https://github.com/{REPO}/pull/\\1)',
87 string=body,
88 )
89
90 # Remove "full changelog" link
91 body = re.sub(
92 pattern=r'\*\*Full Changelog\*\*: https://.*$',
93 repl='',
94 string=body,
95 )
96
97 return body.strip()
98
99
100def update_history(new_version: str, dry_run: bool, force_update: bool) -> None:

Callers 1

update_historyFunction · 0.85

Calls 2

run_commandFunction · 0.90
jsonMethod · 0.45

Tested by

no test coverage detected