Skip to content

Commit e9eba45

Browse files
committed
Push the way Gerrit likes it
1 parent d01b75e commit e9eba45

File tree

1 file changed

+16
-1
lines changed
  • crates/gitbutler-branch-actions/src

1 file changed

+16
-1
lines changed

crates/gitbutler-branch-actions/src/stack.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::{Context, Result};
2+
use but_core::RepositoryExt;
23
use gitbutler_command_context::CommandContext;
34
use gitbutler_oplog::entry::{OperationKind, SnapshotDetails};
45
use gitbutler_oplog::{OplogExt, SnapshotExt};
@@ -189,6 +190,10 @@ pub fn push_stack(
189190
remote: default_target.push_remote_name(),
190191
branch_to_remote: vec![],
191192
};
193+
let gerrit_mode = gix_repo
194+
.git_settings()?
195+
.gitbutler_gerrit_mode
196+
.unwrap_or(false);
192197

193198
let force_push_protection = !skip_force_push_protection && ctx.project().force_push_protection;
194199

@@ -230,12 +235,22 @@ pub fn push_stack(
230235
}
231236
}
232237

238+
let refspec = if gerrit_mode {
239+
Some(format!(
240+
"{}:refs/for/{}",
241+
push_details.head,
242+
default_target.branch.branch()
243+
))
244+
} else {
245+
None
246+
};
247+
233248
ctx.push(
234249
push_details.head,
235250
&push_details.remote_refname,
236251
with_force,
237252
force_push_protection,
238-
None,
253+
refspec,
239254
Some(Some(stack.id)),
240255
)?;
241256

0 commit comments

Comments
 (0)