Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions crates/gitbutler-branch-actions/src/squash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,25 @@ fn do_squash_commits(
let source_commits_without_destination = source_commits
.iter()
.filter(|&commit| commit.id() != destination_commit.id());
let gerrit_mode = but_core::RepositoryExt::git_settings(&ctx.gix_repo()?)?
.gitbutler_gerrit_mode
.unwrap_or(false);

// Squash commit messages string separating with newlines
let new_message = Some(destination_commit)
.into_iter()
.chain(source_commits_without_destination)
.filter_map(|c| {
let msg = c.message().unwrap_or_default();
let msg = if gerrit_mode {
// Remove lines containing Change-Id: <hash> only if gerrit mode is enabled
msg.lines()
.filter(|line| !line.trim_start().starts_with("Change-Id: I"))
.collect::<Vec<_>>()
.join("\n")
} else {
msg.to_string()
};
(!msg.trim().is_empty()).then_some(msg)
})
.collect::<Vec<_>>()
Expand Down
1 change: 1 addition & 0 deletions crates/gitbutler-repo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ gitbutler-diff.workspace = true
but-rebase.workspace = true
but-core.workspace = true
but-status.workspace = true
but-gerrit.workspace = true
uuid.workspace = true
itertools = "0.14"
toml.workspace = true
Expand Down
4 changes: 4 additions & 0 deletions crates/gitbutler-repo/src/repository_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ impl RepositoryExt for git2::Repository {
}
}

if repo.git_settings()?.gitbutler_gerrit_mode.unwrap_or(false) {
but_gerrit::set_trailers(&mut commit);
}

// TODO: extra-headers should be supported in `gix` directly.
let oid = gix_to_git2_oid(repo.write_object(&commit)?);

Expand Down
Loading