Skip to content

forge: merge API#12379

Merged
estib-vega merged 1 commit intomasterfrom
merge-review
Feb 16, 2026
Merged

forge: merge API#12379
estib-vega merged 1 commit intomasterfrom
merge-review

Conversation

@estib-vega
Copy link
Contributor

Add an API to merge a given review by it’s ID.

@vercel
Copy link

vercel bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Feb 16, 2026 7:29pm

Request Review

@github-actions github-actions bot added the rust Pull requests that update Rust code label Feb 16, 2026
Add an API to merge a given review by it’s ID.
@estib-vega estib-vega marked this pull request as ready for review February 16, 2026 21:55
Copilot AI review requested due to automatic review settings February 16, 2026 21:55
@estib-vega estib-vega merged commit 08a0964 into master Feb 16, 2026
30 checks passed
@estib-vega estib-vega deleted the merge-review branch February 16, 2026 21:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds a merge API for reviews (pull requests/merge requests) to the GitButler forge integration. The implementation follows the established patterns for forge operations and adds support for both GitHub and GitLab.

Changes:

  • Added merge_review function to the forge API that merges a review by its ID
  • Implemented GitHub PR merge via the GitHub API (PUT endpoint with merge method options)
  • Implemented GitLab MR merge via the GitLab API (PUT endpoint with squash option)

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
crates/but-api/src/legacy/forge.rs Adds the merge_review API function that accepts a review ID and delegates to the forge-specific implementation
crates/but-forge/src/lib.rs Exports the new merge_review function from the review module
crates/but-forge/src/review.rs Implements the core merge_review logic that routes to GitHub or GitLab based on forge type
crates/but-github/src/client.rs Adds merge_pull_request method and supporting types (MergeMethod enum, MergePullRequestParams)
crates/but-github/src/lib.rs Exports the new merge-related types for public API use
crates/but-github/src/pr.rs Adds merge wrapper function that creates the client and invokes the merge operation
crates/but-gitlab/src/client.rs Adds merge_merge_request method and MergeMergeRequestParams struct
crates/but-gitlab/src/lib.rs Exports the new MergeMergeRequestParams type
crates/but-gitlab/src/mr.rs Adds merge wrapper function with a typo in the error message
crates/but-server/src/lib.rs Registers the merge_review command handler in the server command dispatcher
crates/gitbutler-tauri/src/main.rs Registers the Tauri command for merge_review

GitLabClient::from_storage(storage, preferred_account)?
.merge_merge_request(&params)
.await
.context("Faile to merge MR")
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

Spelling error in error message: "Faile" should be "Failed".

Suggested change
.context("Faile to merge MR")
.context("Failed to merge MR")

Copilot uses AI. Check for mistakes.
}
}

/// Merge a review to it's target branch
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

Grammar error in comment: "it's" should be "its" (possessive form, not contraction).

Suggested change
/// Merge a review to it's target branch
/// Merge a review to its target branch

Copilot uses AI. Check for mistakes.
let response = self.client.put(&url).json(&body).send().await?;

if !response.status().is_success() {
bail!("Failed to merge merge request: {}", response.status());
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

Consider including the response body in the error message for better debugging. Similar to the pattern used in create_merge_request at line 166 of this file, the error could be:

let status = response.status();
let error_text = response.text().await.unwrap_or_default();
bail!("Failed to merge merge request: {status} - {error_text}")

This provides more context about why the merge failed (e.g., conflicts, permissions, CI checks).

Suggested change
bail!("Failed to merge merge request: {}", response.status());
let status = response.status();
let error_text = response.text().await.unwrap_or_default();
bail!("Failed to merge merge request: {status} - {error_text}");

Copilot uses AI. Check for mistakes.
let response = self.client.put(&url).json(&body).send().await?;

if !response.status().is_success() {
bail!("Failed to merge pull request: {}", response.status());
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

Consider including the response body in the error message for better debugging. Similar to the pattern used in GitLab's create_merge_request (crates/but-gitlab/src/client.rs:166), the error could be:

let status = response.status();
let error_text = response.text().await.unwrap_or_default();
bail!("Failed to merge pull request: {status} - {error_text}")

This provides more context about why the merge failed (e.g., conflicts, permissions, required checks).

Suggested change
bail!("Failed to merge pull request: {}", response.status());
let status = response.status();
let error_text = response.text().await.unwrap_or_default();
bail!("Failed to merge pull request: {status} - {error_text}");

Copilot uses AI. Check for mistakes.
let preferred_account = preferred_forge_user.as_ref().and_then(|user| user.github());
let pr_number = review_number
.try_into()
.context("PR: Failed to cast usize to i64, somehow")?;
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

The error message should be more user-friendly and consistent with the pattern used in other functions. Change "PR: Failed to cast usize to i64, somehow" to "PR number is too large" to match the error message in but_github::pr::get (line 54 of crates/but-github/src/pr.rs).

Suggested change
.context("PR: Failed to cast usize to i64, somehow")?;
.context("PR number is too large")?;

Copilot uses AI. Check for mistakes.
let project_id = GitLabProjectId::new(owner, repo);
let mr_iid = review_number
.try_into()
.context("MR: Failed to cast usize to i64, somehow")?;
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

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

The error message should be more user-friendly and consistent with the pattern used in other functions. Change "MR: Failed to cast usize to i64, somehow" to "MR number is too large" to match the error message in but_gitlab::mr::get (line 52 of crates/but-gitlab/src/mr.rs).

Suggested change
.context("MR: Failed to cast usize to i64, somehow")?;
.context("MR number is too large")?;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant