Skip to content

Commit e6c8c4a

Browse files
wphillipmoorewphillipmoore-claude
andauthored
fix: sync prepare_release.py merge message fix from canonical (#291)
Fixes #290 Co-authored-by: wphillipmoore-claude <255925739+wphillipmoore-claude@users.noreply.github.com>
1 parent 394b2b6 commit e6c8c4a

1 file changed

Lines changed: 17 additions & 13 deletions

File tree

scripts/dev/prepare_release.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,19 @@ def create_release_branch(branch: str) -> None:
150150
run_command(("git", "checkout", "-b", branch))
151151

152152

153-
def merge_main() -> None:
153+
def merge_main(version: str) -> None:
154154
"""Merge main into the release branch to incorporate prior release history.
155155
156156
This prevents CHANGELOG.md merge conflicts by ensuring the release branch
157157
has main's version of the changelog before git-cliff regenerates it.
158+
Uses a conventional commit message to satisfy commit-msg hooks.
158159
"""
159160
print("Merging main into release branch...")
160161
run_command(("git", "fetch", "origin", "main"))
161-
run_command(("git", "merge", "origin/main", "--no-edit"))
162+
run_command((
163+
"git", "merge", "origin/main",
164+
"-m", f"chore: merge main into release/{version}",
165+
))
162166

163167

164168
def generate_changelog(version: str) -> bool:
@@ -189,18 +193,18 @@ def create_pr(version: str, issue: int) -> str:
189193
"""Create a PR to main and return the PR URL."""
190194
print("Creating pull request to main...")
191195
title = f"release: {version}"
192-
body = f"## Summary\n\nRelease {version}\n\nRef #{issue}\n\nGenerated with `prepare_release.py`\n"
196+
body = (
197+
f"## Summary\n\n"
198+
f"Release {version}\n\n"
199+
f"Ref #{issue}\n\n"
200+
f"Generated with `prepare_release.py`\n"
201+
)
193202
result = subprocess.run( # noqa: S603
194203
(
195-
"gh",
196-
"pr",
197-
"create",
198-
"--base",
199-
"main",
200-
"--title",
201-
title,
202-
"--body",
203-
body,
204+
"gh", "pr", "create",
205+
"--base", "main",
206+
"--title", title,
207+
"--body", body,
204208
),
205209
check=True,
206210
text=True,
@@ -245,7 +249,7 @@ def main() -> int:
245249
print(f"Preparing release {version} ({ecosystem})")
246250

247251
create_release_branch(branch)
248-
merge_main()
252+
merge_main(version)
249253
generate_changelog(version)
250254
push_branch(branch)
251255
url = create_pr(version, args.issue)

0 commit comments

Comments
 (0)