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( pub fn reset(
repository: &git::OpenRepository, repository: &git::OpenRepository,
repo_details: &git::RepoDetails, repo_details: &git::RepoDetails,
branch_name: config::BranchName, branch_name: &config::BranchName,
to_commit: git::GitRef, to_commit: &git::GitRef,
force: git::push::Force, force: &git::push::Force,
) -> Result<()> { ) -> Result<()> {
repository.fetch()?; repository.fetch()?;
repository.push(repo_details, branch_name, to_commit, force) repository.push(repo_details, branch_name, to_commit, force)

View file

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

View file

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

View file

@ -69,9 +69,9 @@ pub fn validate_positions(
if let Err(err) = git::push::reset( if let Err(err) = git::push::reset(
repository, repository,
repo_details, repo_details,
repo_config.branches().next(), &repo_config.branches().next(),
main.into(), &main.into(),
git::push::Force::From(next.clone().into()), &git::push::Force::From(next.clone().into()),
) { ) {
warn!(?err, "Failed to reset next to main"); warn!(?err, "Failed to reset next to main");
return Err(git::validation::positions::Error::FailedToResetBranch { return Err(git::validation::positions::Error::FailedToResetBranch {
@ -99,9 +99,9 @@ pub fn validate_positions(
if let Err(err) = git::push::reset( if let Err(err) = git::push::reset(
repository, repository,
repo_details, repo_details,
repo_config.branches().next(), &repo_config.branches().next(),
main.into(), &main.into(),
git::push::Force::From(next.clone().into()), &git::push::Force::From(next.clone().into()),
) { ) {
warn!(?err, "Failed to reset next to main"); warn!(?err, "Failed to reset next to main");
return Err(git::validation::positions::Error::FailedToResetBranch { 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( if let Err(err) = git::push::reset(
&repository, &repository,
&repo_details, &repo_details,
repo_config.branches().next(), &repo_config.branches().next(),
commit.into(), &commit.into(),
git::push::Force::No, &git::push::Force::No,
) { ) {
warn!(?err, "Failed") warn!(?err, "Failed")
} }
@ -87,9 +87,9 @@ pub async fn advance_main(
if let Err(err) = git::push::reset( if let Err(err) = git::push::reset(
repository, repository,
repo_details, repo_details,
repo_config.branches().main(), &repo_config.branches().main(),
next.into(), &next.into(),
git::push::Force::No, &git::push::Force::No,
) { ) {
warn!(?err, "Failed") warn!(?err, "Failed")
}; };