Skip to content

Commit

Permalink
Restore NotFastForward test
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Apr 18, 2024
1 parent 6eec3b6 commit 9034333
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
24 changes: 13 additions & 11 deletions lib/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1400,24 +1400,26 @@ fn push_refs(
_ => GitPushError::InternalGitError(err),
})
};
if remaining_remote_refs_expected_locations.is_empty() {
push_result?;
Ok(())
} else if !failed_push_negotiations.is_empty() {
if !failed_push_negotiations.is_empty() {
// TODO: move this into `map_err` above (if possible) once
// https://github.com/rust-lang/git2-rs/issues/1042 is fully resolved.
assert!(push_result.is_err());
Err(GitPushError::RefInUnexpectedLocation(
failed_push_negotiations,
))
} else {
Err(GitPushError::RefUpdateRejected(
remaining_remote_refs_expected_locations
.keys()
.sorted()
.map(|name| name.to_string())
.collect(),
))
push_result?;
if remaining_remote_refs_expected_locations.is_empty() {
Ok(())
} else {
Err(GitPushError::RefUpdateRejected(
remaining_remote_refs_expected_locations
.keys()
.sorted()
.map(|name| name.to_string())
.collect(),
))
}
}
}

Expand Down
6 changes: 1 addition & 5 deletions lib/tests/test_git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2722,11 +2722,7 @@ fn test_push_branches_not_fast_forward() {
);
assert_debug_snapshot!(result, @r###"
Err(
RefUpdateRejected(
[
"refs/heads/main",
],
),
NotFastForward,
)
"###);
}
Expand Down

0 comments on commit 9034333

Please sign in to comment.