Skip to content

Refactor commit module to seperate folders#12899

Closed
Caleb-T-Owens wants to merge 1 commit intomasterfrom
refactor-but-api-commit-to-seperate-modules
Closed

Refactor commit module to seperate folders#12899
Caleb-T-Owens wants to merge 1 commit intomasterfrom
refactor-but-api-commit-to-seperate-modules

Conversation

@Caleb-T-Owens
Copy link
Contributor

As I’m about to work on dry-runs, I really wanted to split this up because there was just too much going on in this one file

Copilot AI review requested due to automatic review settings March 18, 2026 10:19
@vercel
Copy link

vercel bot commented Mar 18, 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 Mar 18, 2026 10:50am

Request Review

@github-actions github-actions bot added rust Pull requests that update Rust code CLI The command-line program `but` labels Mar 18, 2026
@Caleb-T-Owens Caleb-T-Owens force-pushed the refactor-but-api-commit-to-seperate-modules branch from 496203f to 0a22566 Compare March 18, 2026 10:20
@Caleb-T-Owens Caleb-T-Owens marked this pull request as draft March 18, 2026 10:22
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

Refactors the but-api commit APIs by splitting the former monolithic crates/but-api/src/commit.rs into a dedicated commit/ module with per-endpoint files and shared types, while updating legacy callers to use the new RelativeTo location/type.

Changes:

  • Replaced crates/but-api/src/commit.rs with a crates/but-api/src/commit/ module layout (amend, create, insert_blank, move_changes, move_commit, reword, types, json).
  • Moved commit result structs into commit/types.rs and added JSON transport structs/enums into commit/json.rs.
  • Updated a couple of legacy call sites to reference commit::json::RelativeTo instead of the previous commit::ui::RelativeTo.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/but/src/command/legacy/commit.rs Updates blank-commit insertion to use the new but_api::commit::json::RelativeTo path.
crates/but-api/src/legacy/absorb.rs Switches internal legacy absorb logic to use crate::commit::json::RelativeTo.
crates/but-api/src/commit/mod.rs New commit module entrypoint re-exporting commit endpoints and result types.
crates/but-api/src/commit/json.rs Introduces JSON/UI transport types for commit APIs, including RelativeTo.
crates/but-api/src/commit/types.rs Adds shared commit API result structs (create/move/reword/insert blank).
crates/but-api/src/commit/amend.rs Adds amend endpoint implementation using the new module structure.
crates/but-api/src/commit/create.rs Adds create endpoint implementation using the new module structure.
crates/but-api/src/commit/insert_blank.rs Adds insert-blank endpoint implementation using the new module structure.
crates/but-api/src/commit/move_changes.rs Adds move/uncommit-changes endpoint implementation using the new module structure.
crates/but-api/src/commit/move_commit.rs Adds move-commit endpoint implementation using the new module structure.
crates/but-api/src/commit/reword.rs Adds reword endpoint implementation using the new module structure.
crates/but-api/src/commit.rs Removes the old monolithic commit API module.

Comment on lines +9 to +11
/// JSON transport types for commit APIs.
// Ideally, this would be private and only used for transport, but we don't have
// a good parameter mapping solution at the minute.

/// Outcome after creating a commit.
pub struct CommitCreateResult {
/// If the commit was successfully created. This should only be none if all the DiffSpecs were rejected.
Comment on lines +15 to +17
/// TODO(CTO): Create a way of extracting _all_ mapped commits. Copoilot, have
/// made linear ticket GB-980 for this. I will do this in a follow up PR. Please
/// don't complain.
Comment on lines +10 to +13
/// Moves commit, no snapshots. No strings attached.
///
/// Returns the replaced that resulted from the operation.
pub fn commit_move_only(
Comment on lines +36 to +39
/// Moves a commit within or across stacks.
///
/// Returns the replaced that resulted from the operation.
#[but_api_macros::but_api(napi, crate::commit::json::UICommitMoveResult)]
@Caleb-T-Owens Caleb-T-Owens force-pushed the refactor-but-api-commit-to-seperate-modules branch from 0a22566 to 9ddaa88 Compare March 18, 2026 10:38
As I’m about to work on dry-runs, I really wanted to split this up because there was just too much going on in this one file
@Caleb-T-Owens Caleb-T-Owens force-pushed the refactor-but-api-commit-to-seperate-modules branch from 9ddaa88 to df6e87b Compare March 18, 2026 10:50
@Caleb-T-Owens Caleb-T-Owens marked this pull request as ready for review March 18, 2026 10:50
Copilot AI review requested due to automatic review settings March 18, 2026 10:50
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

Refactors the Rust but_api::commit surface from a single large module into a structured set of submodules (create/amend/reword/move/etc.), and updates all in-repo call sites (Tauri app, server router, and but CLI) to use the new paths while keeping existing HTTP/Tauri command endpoints working.

Changes:

  • Split crates/but-api/src/commit.rs into crates/but-api/src/commit/* modules and introduced shared result/JSON transport types.
  • Updated but CLI commands and legacy flows to use the new but_api::commit::{...} module layout (including RelativeTo moving under commit::json).
  • Updated Tauri invoke_handler registrations and but-server routes to reference the new module paths.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/gitbutler-tauri/src/main.rs Updates Tauri command registrations to the new but_api::commit::<submodule>::tauri_* paths.
crates/but/src/command/legacy/status/tui/mod.rs Adjusts imports and call sites for reword/insert-blank to new but_api::commit module structure.
crates/but/src/command/legacy/rub/squash.rs Updates reword calls to but_api::commit::reword::commit_reword_only.
crates/but/src/command/legacy/reword.rs Updates reword calls to new module path.
crates/but/src/command/legacy/commit.rs Updates create/insert-blank usage and RelativeTo import path to commit::json.
crates/but/src/command/commit/move.rs Updates move implementation to commit::move_commit::commit_move and commit::json::RelativeTo.
crates/but/src/command/commit/file.rs Updates move-changes/uncommit-changes calls to new submodules.
crates/but-server/src/lib.rs Moves/updates routes to point at new but_api::commit::<submodule>::*_cmd handlers.
crates/but-api/src/legacy/absorb.rs Updates internal insert-blank impl import and RelativeTo path after commit module split.
crates/but-api/src/commit/uncommit_changes.rs Adds dedicated module for uncommit-changes APIs (with optional oplog + assignment support).
crates/but-api/src/commit/types.rs Introduces shared result structs for commit operations.
crates/but-api/src/commit/reword.rs Adds dedicated reword APIs (with optional oplog snapshotting).
crates/but-api/src/commit/move_commit.rs Adds dedicated move-commit APIs (with optional oplog snapshotting).
crates/but-api/src/commit/move_changes.rs Adds dedicated move-changes APIs (with optional oplog snapshotting).
crates/but-api/src/commit/mod.rs New commit module root wiring up submodules.
crates/but-api/src/commit/json.rs Adds JSON transport types, schema registration, and RelativeTo transport enum.
crates/but-api/src/commit/insert_blank.rs Adds dedicated insert-blank APIs (with optional oplog snapshotting).
crates/but-api/src/commit/create.rs Adds dedicated create APIs (with optional oplog snapshotting).
crates/but-api/src/commit/amend.rs Adds dedicated amend APIs (with optional oplog snapshotting).
crates/but-api/src/commit.rs Removes the previous monolithic commit module implementation.

Comment on lines +10 to +12
/// Moves commit, no snapshots. No strings attached.
///
/// Returns the replaced that resulted from the operation.
pub mod reword;
/// Shared types for commit APIs.
pub mod types;
/// Endpoints for uncommitting commits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI The command-line program `but` rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants