Refactor commit module to seperate folders#12899
Refactor commit module to seperate folders#12899Caleb-T-Owens wants to merge 1 commit intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
496203f to
0a22566
Compare
There was a problem hiding this comment.
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.rswith acrates/but-api/src/commit/module layout (amend,create,insert_blank,move_changes,move_commit,reword,types,json). - Moved commit result structs into
commit/types.rsand added JSON transport structs/enums intocommit/json.rs. - Updated a couple of legacy call sites to reference
commit::json::RelativeToinstead of the previouscommit::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. |
| /// 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. |
| /// 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. |
| /// Moves commit, no snapshots. No strings attached. | ||
| /// | ||
| /// Returns the replaced that resulted from the operation. | ||
| pub fn commit_move_only( |
| /// 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)] |
0a22566 to
9ddaa88
Compare
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
9ddaa88 to
df6e87b
Compare
There was a problem hiding this comment.
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.rsintocrates/but-api/src/commit/*modules and introduced shared result/JSON transport types. - Updated
butCLI commands and legacy flows to use the newbut_api::commit::{...}module layout (includingRelativeTomoving undercommit::json). - Updated Tauri
invoke_handlerregistrations andbut-serverroutes 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. |
| /// 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. |
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