diff --git a/lib/src/git.rs b/lib/src/git.rs index 58dd02dc024..5e7d1591ee8 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -1226,9 +1226,8 @@ pub struct GitBranchPushTargets { pub struct GitRefUpdate { pub qualified_name: String, - // TODO: We want this to be a `current_target: Option` for the expected current - // commit on the remote. It's a blunt "force" option instead until git2-rs supports the - // "push negotiation" callback (https://github.com/rust-lang/git2-rs/issues/733). + pub expected_current_target: Option, + // Short-term TODO: Delete `force` pub force: bool, pub new_target: Option, } @@ -1247,6 +1246,7 @@ pub fn push_branches( .map(|(branch_name, update)| GitRefUpdate { qualified_name: format!("refs/heads/{branch_name}"), force: targets.force_pushed_branches.contains(branch_name), + expected_current_target: update.old_target.clone(), new_target: update.new_target.clone(), }) .collect_vec(); diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index 546b751a2f0..a78523532f7 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -2774,6 +2774,7 @@ fn test_push_updates_success() { &[GitRefUpdate { qualified_name: "refs/heads/main".to_string(), force: false, + expected_current_target: Some(setup.initial_commit.id().clone()), new_target: Some(setup.new_commit.id().clone()), }], git::RemoteCallbacks::default(), @@ -2810,6 +2811,7 @@ fn test_push_updates_no_such_remote() { &[GitRefUpdate { qualified_name: "refs/heads/main".to_string(), force: false, + expected_current_target: Some(setup.initial_commit.id().clone()), new_target: Some(setup.new_commit.id().clone()), }], git::RemoteCallbacks::default(), @@ -2828,6 +2830,7 @@ fn test_push_updates_invalid_remote() { &[GitRefUpdate { qualified_name: "refs/heads/main".to_string(), force: false, + expected_current_target: Some(setup.initial_commit.id().clone()), new_target: Some(setup.new_commit.id().clone()), }], git::RemoteCallbacks::default(),