refactor: git::push::reset takes all params as refs
All checks were successful
Rust / build (push) Successful in 59s
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful

This commit is contained in:
Paul Campbell 2024-06-08 21:13:31 +01:00
parent c6a1d2c21b
commit dcd94736a9
6 changed files with 27 additions and 27 deletions

View file

@ -45,9 +45,9 @@ pub enum Error {
pub fn reset(
repository: &git::OpenRepository,
repo_details: &git::RepoDetails,
branch_name: config::BranchName,
to_commit: git::GitRef,
force: git::push::Force,
branch_name: &config::BranchName,
to_commit: &git::GitRef,
force: &git::push::Force,
) -> Result<()> {
repository.fetch()?;
repository.push(repo_details, branch_name, to_commit, force)

View file

@ -129,9 +129,9 @@ impl OpenRepositoryLike for MockOpenRepository {
fn push(
&self,
repo_details: &RepoDetails,
branch_name: git_next_config::BranchName,
to_commit: crate::GitRef,
force: crate::push::Force,
branch_name: &git_next_config::BranchName,
to_commit: &crate::GitRef,
force: &crate::push::Force,
) -> core::result::Result<(), crate::push::Error> {
self.inner
.lock()
@ -179,9 +179,9 @@ impl OpenRepositoryLike for InnerMockOpenRepository {
fn push(
&self,
_repo_details: &RepoDetails,
_branch_name: git_next_config::BranchName,
_to_commit: crate::GitRef,
_force: crate::push::Force,
_branch_name: &git_next_config::BranchName,
_to_commit: &crate::GitRef,
_force: &crate::push::Force,
) -> core::result::Result<(), crate::push::Error> {
todo!()
}

View file

@ -34,9 +34,9 @@ pub trait OpenRepositoryLike {
fn push(
&self,
repo_details: &git::RepoDetails,
branch_name: config::BranchName,
to_commit: git::GitRef,
force: git::push::Force,
branch_name: &config::BranchName,
to_commit: &git::GitRef,
force: &git::push::Force,
) -> git::push::Result<()>;
/// List of commits in a branch, optionally up-to any specified commit.

View file

@ -73,9 +73,9 @@ impl super::OpenRepositoryLike for RealOpenRepository {
fn push(
&self,
repo_details: &git::RepoDetails,
branch_name: config::BranchName,
to_commit: git::GitRef,
force: git::push::Force,
branch_name: &config::BranchName,
to_commit: &git::GitRef,
force: &git::push::Force,
) -> Result<(), git::push::Error> {
let origin = repo_details.origin();
let force = match force {

View file

@ -69,9 +69,9 @@ pub fn validate_positions(
if let Err(err) = git::push::reset(
repository,
repo_details,
repo_config.branches().next(),
main.into(),
git::push::Force::From(next.clone().into()),
&repo_config.branches().next(),
&main.into(),
&git::push::Force::From(next.clone().into()),
) {
warn!(?err, "Failed to reset next to main");
return Err(git::validation::positions::Error::FailedToResetBranch {
@ -99,9 +99,9 @@ pub fn validate_positions(
if let Err(err) = git::push::reset(
repository,
repo_details,
repo_config.branches().next(),
main.into(),
git::push::Force::From(next.clone().into()),
&repo_config.branches().next(),
&main.into(),
&git::push::Force::From(next.clone().into()),
) {
warn!(?err, "Failed to reset next to main");
return Err(git::validation::positions::Error::FailedToResetBranch {

View file

@ -33,9 +33,9 @@ pub async fn advance_next(
if let Err(err) = git::push::reset(
&repository,
&repo_details,
repo_config.branches().next(),
commit.into(),
git::push::Force::No,
&repo_config.branches().next(),
&commit.into(),
&git::push::Force::No,
) {
warn!(?err, "Failed")
}
@ -87,9 +87,9 @@ pub async fn advance_main(
if let Err(err) = git::push::reset(
repository,
repo_details,
repo_config.branches().main(),
next.into(),
git::push::Force::No,
&repo_config.branches().main(),
&next.into(),
&git::push::Force::No,
) {
warn!(?err, "Failed")
};