Skip to content

Persist change id in lower level commit function#13759

Open
Caleb-T-Owens wants to merge 1 commit into
masterfrom
persist-change-id-in-more-cases
Open

Persist change id in lower level commit function#13759
Caleb-T-Owens wants to merge 1 commit into
masterfrom
persist-change-id-in-more-cases

Conversation

@Caleb-T-Owens
Copy link
Copy Markdown
Contributor

By persisting the determined change id in the commit.rs create function, we’re able to handle it well in the new_commit function, which means that operations like reword will persist their change ids as well

Copilot AI review requested due to automatic review settings May 12, 2026 09:24
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 ensures GitButler “change-id” values are persisted when commits are recreated at a lower level (in but-rebase::commit::create), so higher-level operations like reword/amend keep stable change-ids across rewritten commits.

Changes:

  • Extended but-rebase::commit::create to optionally set/override the commit’s change-id header during commit creation.
  • Updated rebase/commit creation call sites to pass through the existing computed change-id where appropriate.
  • Refreshed snapshot-based tests to account for the (expected) new commit hashes produced by persisted headers.

Reviewed changes

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

Show a summary per file
File Description
crates/gitbutler-edit-mode/src/lib.rs Updates commit creation call to new create(..., change_id) signature.
crates/but/tests/but/command/reword.rs Updates snapshots due to new commit hashes after reword.
crates/but-workspace/tests/workspace/commit/uncommit_changes.rs Updates commit-graph snapshots to new hashes.
crates/but-workspace/tests/workspace/commit/squash_commits.rs Updates commit-graph snapshots to new hashes.
crates/but-workspace/tests/workspace/commit/reword.rs Updates commit-graph snapshots to new hashes after reword.
crates/but-workspace/tests/workspace/commit/move_changes.rs Updates commit mapping + graph snapshots due to rewritten commits.
crates/but-workspace/src/commit_engine/mod.rs Persists existing change-id when amending via but_rebase::commit::create.
crates/but-rebase/tests/rebase/graph_rebase/sha256.rs Updates SHA-256 snapshot expectations due to rewritten commit metadata.
crates/but-rebase/src/merge.rs Restricts octopus helper visibility and updates commit creation call signature.
crates/but-rebase/src/lib.rs Updates internal commit creation calls to new signature.
crates/but-rebase/src/graph_rebase/commit.rs Ensures Editor::new_commit_untracked persists the commit’s change-id.
crates/but-rebase/src/graph_rebase/cherry_pick.rs Ensures recreated commits keep the original change-id; removes now-unneeded header injection.
crates/but-rebase/src/commit.rs Adds change_id: Option<ChangeId> support and writes it into commit headers when provided.
crates/but-rebase/src/cherry_pick.rs Updates commit creation calls to the new signature.
crates/but-core/src/commit/mod.rs Adds Headers::empty() convenience constructor used by lower-level commit creation.

Comment on lines +89 to +90
/// change_id can be used to either ste or override the existing change_id
/// header.
impl Headers {
/// Create a headers structure with both change_id and conflicted unset.
///
/// This is only useful if you're going to set one of the properties right after. You _probably_ want to
@Caleb-T-Owens Caleb-T-Owens force-pushed the persist-change-id-in-more-cases branch 2 times, most recently from 4e8f46b to d9e15d8 Compare May 12, 2026 12:39
@github-actions github-actions Bot added rust Pull requests that update Rust code CLI The command-line program `but` labels May 12, 2026
By persisting the determined change id in the commit.rs `create` function, we’re able to handle it well in the `new_commit` function, which means that operations like reword will persist their change ids as well
Copilot AI review requested due to automatic review settings May 12, 2026 13:12
@Caleb-T-Owens Caleb-T-Owens force-pushed the persist-change-id-in-more-cases branch from d9e15d8 to 4252a2a Compare May 12, 2026 13:12
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

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

/// Signatures will be removed automatically if signing is disabled to prevent an amended commit
/// to use the old signature.
///
/// change_id can be used to either ste or override the existing change_id
}

if let Some(change_id) = change_id {
let mut headers = Headers::try_from_commit(&commit).unwrap_or_else(Headers::empty);
impl Headers {
/// Create a headers structure with both change_id and conflicted unset.
///
/// This is only useful if you're going to set one of the properties right after. You _probably_ want to
/// However, if we re-merge a commit that was signed before it's likely a user-commit that should be treated accordingly.
/// Thanks to this logic, the caller shouldn't have to steer signing.
pub fn octopus(
pub(crate) fn octopus(
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