Skip to content

add-bytes-for-referring-to-reference#12884

Merged
Caleb-T-Owens merged 3 commits intomasterfrom
add-bytes-for-referring-to-reference
Mar 17, 2026
Merged

add-bytes-for-referring-to-reference#12884
Caleb-T-Owens merged 3 commits intomasterfrom
add-bytes-for-referring-to-reference

Conversation

@Caleb-T-Owens
Copy link
Copy Markdown
Contributor

@Caleb-T-Owens Caleb-T-Owens commented Mar 17, 2026

Copilot AI review requested due to automatic review settings March 17, 2026 11:00
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 17, 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 17, 2026 3:15pm

Request Review

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.
Copy link
Copy Markdown
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 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 ReferenceBytes variant to RelativeTo enum (Rust + generated TS types) and a fullname_bytes schema helper
  • Unified commitMove and commitMoveToBranch into a single commitMove API that accepts RelativeTo
  • Updated frontend (lite app) to use the unified API with referenceBytes type

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

Comment thread apps/lite/electron/src/ipc.ts
Comment thread apps/lite/electron/src/ipc.ts
@Caleb-T-Owens Caleb-T-Owens force-pushed the add-bytes-for-referring-to-reference branch from e9cb9ea to a832338 Compare March 17, 2026 11:08
@github-actions github-actions Bot added the rust Pull requests that update Rust code label Mar 17, 2026
Copilot AI review requested due to automatic review settings March 17, 2026 11:09
@Caleb-T-Owens Caleb-T-Owens force-pushed the add-bytes-for-referring-to-reference branch from a832338 to 593b92d Compare March 17, 2026 11:09
Copy link
Copy Markdown
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 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 commitMoveToBranch into commitMove by replacing anchorCommitId/anchorRef params with a RelativeTo enum
  • Added ReferenceBytes variant to RelativeTo for byte-serialized ref names, removing the decodeRefName workaround
  • 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

Comment on lines 130 to 132
commitDetailsWithLineStats: (params: CommitDetailsWithLineStatsParams) => Promise<CommitDetails>;
commitInsertBlank: (params: CommitInsertBlankParams) => Promise<UICommitInsertBlankResult>;
commitMove: (params: CommitMoveParams) => Promise<UICommitMoveResult>;
@Caleb-T-Owens Caleb-T-Owens force-pushed the add-bytes-for-referring-to-reference branch from 593b92d to 01cd692 Compare March 17, 2026 11:20
@github-actions github-actions Bot added the CLI The command-line program `but` label Mar 17, 2026
We can consolidate the two functions `commitMove` and `commitMoveToBranch` by using the `RealtiveTo` enum which also means they now support the `referenceBytes` variant
Copilot AI review requested due to automatic review settings March 17, 2026 15:15
@Caleb-T-Owens Caleb-T-Owens force-pushed the add-bytes-for-referring-to-reference branch from 01cd692 to 501f8f6 Compare March 17, 2026 15:15
Copy link
Copy Markdown
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 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 ReferenceBytes variant to RelativeTo and removed the separate commitMoveToBranch API
  • Updated all callers (CLI, Electron IPC, lite UI) to use the unified commitMove with RelativeTo
  • Added fullname_bytes schema helper in but-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
@Caleb-T-Owens Caleb-T-Owens merged commit 054540d into master Mar 17, 2026
41 checks passed
@Caleb-T-Owens Caleb-T-Owens deleted the add-bytes-for-referring-to-reference branch March 17, 2026 15:42
Copy link
Copy Markdown
Collaborator

@Byron Byron left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines -663 to +660
anchor_commit_id: gix::ObjectId,
relative_to: ui::RelativeTo,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

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.

3 participants