Skip to content

Commit

Permalink
add expected_current_target
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Apr 17, 2024
1 parent ea5c9ff commit 3335d9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,9 +1226,8 @@ pub struct GitBranchPushTargets {

pub struct GitRefUpdate {
pub qualified_name: String,
// TODO: We want this to be a `current_target: Option<CommitId>` 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<CommitId>,
// Short-term TODO: Delete `force`
pub force: bool,
pub new_target: Option<CommitId>,
}
Expand All @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions lib/tests/test_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down

0 comments on commit 3335d9d

Please sign in to comment.