add-bytes-for-referring-to-reference#12884
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Currently this is hypothetical, but there could be a reference that when we lossily convert it to utf8 it git then won’t pick it up again when we pass it back. This provides the frontend the option to refer to the original value.
There was a problem hiding this comment.
Pull request overview
This PR consolidates commitMove and commitMoveToBranch into a single commitMove function by introducing a ReferenceBytes variant to the RelativeTo type, allowing byte-based reference targeting. This eliminates lossy string decoding of ref names on the frontend.
Changes:
- Added
ReferenceBytesvariant toRelativeToenum (Rust + generated TS types) and afullname_bytesschema helper - Unified
commitMoveandcommitMoveToBranchinto a singlecommitMoveAPI that acceptsRelativeTo - Updated frontend (lite app) to use the unified API with
referenceBytestype
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/but-schemars/src/lib.rs | Added fullname_bytes schema helper for byte-serialized ref names |
| crates/but-api/src/commit.rs | Unified commit_move and commit_move_to_branch into one function using RelativeTo; added ReferenceBytes variant |
| packages/but-sdk/src/generated/index.js | Removed commitMoveToBranch export |
| packages/but-sdk/src/generated/index.d.ts | Updated commitMove signature; removed commitMoveToBranch; added referenceBytes to RelativeTo |
| apps/lite/ui/src/routes/project-index.tsx | Updated to use unified commitMove with RelativeTo types |
| apps/lite/ui/src/mutations.ts | Removed commitMoveToBranchMutationOptions |
| apps/lite/electron/src/preload.cts | Removed commitMoveToBranch preload binding |
| apps/lite/electron/src/main.ts | Removed commitMoveToBranch IPC handler; updated commitMove handler |
| apps/lite/electron/src/ipc.ts | Updated CommitMoveParams; removed commitMoveToBranch from API interface |
e9cb9ea to
a832338
Compare
a832338 to
593b92d
Compare
There was a problem hiding this comment.
Pull request overview
This PR consolidates commitMove and commitMoveToBranch into a single commitMove API that accepts a RelativeTo parameter, and adds a ReferenceBytes variant to RelativeTo to support non-lossy byte-level reference names (avoiding the previous string decoding workaround).
Changes:
- Merged
commitMoveToBranchintocommitMoveby replacinganchorCommitId/anchorRefparams with aRelativeToenum - Added
ReferenceBytesvariant toRelativeTofor byte-serialized ref names, removing thedecodeRefNameworkaround - Removed all
commitMoveToBranch-specific code across backend and frontend
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/but-api/src/commit.rs | Unified commit_move and commit_move_to_branch into one function using RelativeTo; added ReferenceBytes variant |
| crates/but-schemars/src/lib.rs | Added fullname_bytes schema helper for byte-serialized ref names |
| packages/but-sdk/src/generated/index.js | Removed commitMoveToBranch export |
| packages/but-sdk/src/generated/index.d.ts | Updated commitMove signature; removed commitMoveToBranch; added referenceBytes to RelativeTo |
| apps/lite/ui/src/routes/project-index.tsx | Updated drag-and-drop operations to use unified commitMove with RelativeTo |
| apps/lite/ui/src/mutations.ts | Removed commitMoveToBranchMutationOptions |
| apps/lite/electron/src/main.ts | Updated IPC handler to pass relativeTo instead of separate params |
| apps/lite/electron/src/preload.cts | Removed commitMoveToBranch IPC bridge |
| apps/lite/electron/src/ipc.ts | Updated CommitMoveParams; removed CommitMoveToBranchParams and interface entry |
| commitDetailsWithLineStats: (params: CommitDetailsWithLineStatsParams) => Promise<CommitDetails>; | ||
| commitInsertBlank: (params: CommitInsertBlankParams) => Promise<UICommitInsertBlankResult>; | ||
| commitMove: (params: CommitMoveParams) => Promise<UICommitMoveResult>; |
593b92d to
01cd692
Compare
We can consolidate the two functions `commitMove` and `commitMoveToBranch` by using the `RealtiveTo` enum which also means they now support the `referenceBytes` variant
01cd692 to
501f8f6
Compare
There was a problem hiding this comment.
Pull request overview
This PR consolidates commitMoveToBranch into commitMove by extending the RelativeTo enum with a ReferenceBytes variant, allowing references to be passed as raw bytes instead of lossy UTF-8 strings. This addresses GB-1128 where references in mutations should use bytes instead of strings.
Changes:
- Added
ReferenceBytesvariant toRelativeToand removed the separatecommitMoveToBranchAPI - Updated all callers (CLI, Electron IPC, lite UI) to use the unified
commitMovewithRelativeTo - Added
fullname_bytesschema helper inbut-schemars
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/but-api/src/commit.rs | Added ReferenceBytes variant, removed commitMoveToBranch/commitMoveToBranchOnly, unified into commitMove |
| crates/but-schemars/src/lib.rs | Added fullname_bytes schema helper for byte-serialized FullName |
| crates/but/src/command/commit/move.rs | Updated CLI to use RelativeTo::Commit and RelativeTo::Reference |
| packages/but-sdk/src/generated/index.js | Removed commitMoveToBranch export |
| packages/but-sdk/src/generated/index.d.ts | Updated commitMove signature, added referenceBytes to RelativeTo, removed commitMoveToBranch |
| apps/lite/ui/src/routes/project-index.tsx | Updated drag-and-drop to use unified commitMove with referenceBytes |
| apps/lite/ui/src/mutations.ts | Removed commitMoveToBranchMutationOptions |
| apps/lite/electron/src/main.ts | Removed commitMoveToBranch IPC handler |
| apps/lite/electron/src/preload.cts | Removed commitMoveToBranch preload binding |
| apps/lite/electron/src/ipc.ts | Updated CommitMoveParams, removed CommitMoveToBranchParams |
| #[serde(with = "but_serde::fullname_lossy")] | ||
| #[cfg_attr(feature = "export-schema", schemars(with = "String"))] | ||
| Reference(gix::refs::FullName), | ||
| /// Relative to a reference, this time with teeth |
Byron
left a comment
There was a problem hiding this comment.
Thanks, lots of code deleted, who wouldn't love that!
I found an issue related to the capabilities of the but_api macro that I will try to resolve.
| anchor_commit_id: gix::ObjectId, | ||
| relative_to: ui::RelativeTo, |
There was a problem hiding this comment.
ui types shouldn't be used in the Rust portion of the but-api, instead there should be an unconvoluted type (this ui type has redundancies that aren't needed.
The problem here is that parameter conversion is limited via the but_api macro, which certainly should be used here, and I will try to address that.
Uh oh!
There was an error while loading. Please reload this page.