Write a changelog draft for the release. Args: version: Release version without the leading `v`. commits: Commit subject lines to include as the first changelog draft. Returns: Path to the created changelog file. Raises: ReleaseError: The changelog file
(version: str, commits: list[str])
| 225 | |
| 226 | |
| 227 | def write_changelog(version: str, commits: list[str]) -> Path: |
| 228 | """Write a changelog draft for the release. |
| 229 | |
| 230 | Args: |
| 231 | version: Release version without the leading `v`. |
| 232 | commits: Commit subject lines to include as the first changelog draft. |
| 233 | |
| 234 | Returns: |
| 235 | Path to the created changelog file. |
| 236 | |
| 237 | Raises: |
| 238 | ReleaseError: The changelog file already exists. |
| 239 | """ |
| 240 | changelog_path = REPO_ROOT / "changelogs" / f"v{version}.md" |
| 241 | if changelog_path.exists(): |
| 242 | raise ReleaseError(f"Changelog already exists: {changelog_path}") |
| 243 | |
| 244 | changelog_path.parent.mkdir(parents=True, exist_ok=True) |
| 245 | entries = [f"- {commit}" for commit in commits] or ["- "] |
| 246 | changelog_path.write_text( |
| 247 | "\n".join( |
| 248 | [ |
| 249 | "## What's Changed", |
| 250 | "", |
| 251 | "<!-- Review, group, and polish these entries before publishing. -->", |
| 252 | "", |
| 253 | *entries, |
| 254 | "", |
| 255 | ] |
| 256 | ), |
| 257 | encoding="utf-8", |
| 258 | ) |
| 259 | return changelog_path |
| 260 | |
| 261 | |
| 262 | def create_release_branch(version: str, base_branch: str, remote: str) -> str: |
no test coverage detected