Skip to content

fix(api): Send correct title param when merging a pull request - #4

Open
euxaristia wants to merge 2 commits into
mainfrom
fix/pr-merge-title-param
Open

fix(api): Send correct title param when merging a pull request#4
euxaristia wants to merge 2 commits into
mainfrom
fix/pr-merge-title-param

Conversation

@euxaristia

@euxaristia euxaristia commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

gt pr merge --message had no effect. The Gitee v5 merge endpoint (PUT /repos/{owner}/{repo}/pulls/{number}/merge) expects the merge commit title under the title field, but the client sent it as merge_commit_message, which the API does not recognize. As a result the flag value was silently discarded and every merge used the default title.

Changes

internal/api/client.go

  • MergePR now sends the merge title under the title field so pr merge --message is honored.

Test plan

  • go build ./... clean
  • go test ./internal/api/ pass (incl. payload title assertion added in the fixup commit)

Prior reviewer feedback addressed

  • ✅ CodeRabbit nitpick: assert the merge payload field in TestMergePR (review). Added request-body decoding/assertion in the test server merge handler so the test fails if the legacy merge_commit_message field regresses.

The Gitee v5 merge endpoint (PUT /repos/{owner}/{repo}/pulls/{number}/merge)
accepts a "title" field for the merge commit, not "merge_commit_message".
Because the payload used an unrecognized key, the users pr merge --message
value was silently dropped and every merge fell back to the default title.
Send the value under "title" so the flag takes effect.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Client.MergePR now sends title instead of merge_commit_message in the merge endpoint request payload. Method signatures, retries, and response handling are unchanged.

Changes

Merge request payload

Layer / File(s) Summary
Merge payload field
internal/api/client.go
The merge request payload uses title instead of merge_commit_message.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Poem

I’m a bunny with a merge in sight,
Swapping one field to make it right.
A title hops into the payload with cheer,
While retries and responses stay steady here.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the merge payload fix and is specific to the main change.
Description check ✅ Passed The description matches the changeset by explaining the merge title field fix and test coverage.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/api/client.go (1)

354-354: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert the merge payload field in TestMergePR.

The current test only checks for a successful response, so it would also pass with the old merge_commit_message field. Decode the request body in internal/api/client_test.go:81-83 and assert that title equals "merge msg" to lock in this API contract.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/api/client.go` at line 354, Update TestMergePR to decode the request
body captured by the existing test handler and assert that its title field
equals "merge msg". Use the decoded payload to verify the merge request sends
the title key, ensuring the test fails if the legacy merge_commit_message field
is used.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/api/client.go`:
- Line 354: Update TestMergePR to decode the request body captured by the
existing test handler and assert that its title field equals "merge msg". Use
the decoded payload to verify the merge request sends the title key, ensuring
the test fails if the legacy merge_commit_message field is used.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e3d0a796-7ead-4d18-97cd-e057a35c01af

📥 Commits

Reviewing files that changed from the base of the PR and between d880cc3 and 02cc2e4.

📒 Files selected for processing (1)
  • internal/api/client.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 15, 2026
The CodeRabbit review (PR #4) flagged that TestMergePR only checked for a
successful response, so it would pass even with the old, incorrect
merge_commit_message field. Decode the request body in the test server
merge handler and assert the title field is present, locking in the API
contract fixed by the MergePR title change.
@euxaristia

Copy link
Copy Markdown
Owner Author

Pushed a fixup commit addressing the CodeRabbit nitpick: the test server merge handler now decodes the request body and asserts the title field is present, so TestMergePR fails if the legacy merge_commit_message field ever regresses. Added a ## Prior reviewer feedback addressed section to the PR body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant