Persist change id in lower level commit function#13759
Open
Caleb-T-Owens wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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::createto 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 |
4e8f46b to
d9e15d8
Compare
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
d9e15d8 to
4252a2a
Compare
| /// 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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By persisting the determined change id in the commit.rs
createfunction, we’re able to handle it well in thenew_commitfunction, which means that operations like reword will persist their change ids as well