Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a minor simplification to CommitBuilder::write #3178

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions lib/src/commit_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,6 @@ impl CommitBuilder<'_> {
}

pub fn write(mut self) -> BackendResult<Commit> {
let mut rewrite_source_id = None;
if let Some(rewrite_source) = self.rewrite_source {
if *rewrite_source.change_id() == self.commit.change_id {
rewrite_source_id.replace(rewrite_source.id().clone());
}
}

let sign_settings = &self.sign_settings;
let store = self.mut_repo.store();

Expand All @@ -202,9 +195,11 @@ impl CommitBuilder<'_> {
let commit = self
.mut_repo
.write_commit(self.commit, signing_fn.as_deref_mut())?;
if let Some(rewrite_source_id) = rewrite_source_id {
self.mut_repo
.record_rewritten_commit(rewrite_source_id, commit.id().clone())
if let Some(rewrite_source) = self.rewrite_source {
if rewrite_source.change_id() == commit.change_id() {
self.mut_repo
.record_rewritten_commit(rewrite_source.id().clone(), commit.id().clone());
}
}
Ok(commit)
}
Expand Down