diff --git a/Cargo.toml b/Cargo.toml index 8e82fabb..5085fa54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ bytes = "1.6" ulid = "1.1" warp = "0.3" -# error handling +# boilerplate derive_more = { version = "1.0.0-beta.6", features = [ "as_ref", "constructor", @@ -68,6 +68,8 @@ derive_more = { version = "1.0.0-beta.6", features = [ "deref", "from", ] } + +# error handling terrors = "0.3" # file watcher diff --git a/crates/git/src/lib.rs b/crates/git/src/lib.rs index b4627df1..1fea9175 100644 --- a/crates/git/src/lib.rs +++ b/crates/git/src/lib.rs @@ -4,9 +4,9 @@ pub mod fetch; mod generation; mod git_ref; mod git_remote; +pub mod push; mod repo_details; pub mod repository; -pub mod reset; pub mod validate; pub use commit::Commit; @@ -14,7 +14,7 @@ pub use fetch::fetch; pub use generation::Generation; pub use git_ref::GitRef; pub use git_remote::GitRemote; +pub use push::push; pub use repo_details::RepoDetails; pub use repository::Repository; -pub use reset::reset; pub use validate::validate; diff --git a/crates/git/src/reset.rs b/crates/git/src/push.rs similarity index 99% rename from crates/git/src/reset.rs rename to crates/git/src/push.rs index 5d3f0bbb..c4a506a2 100644 --- a/crates/git/src/reset.rs +++ b/crates/git/src/push.rs @@ -22,7 +22,7 @@ impl std::fmt::Display for Force { // TODO: (#72) reimplement using `gix` #[tracing::instrument(skip_all, fields(branch = %branch_name, to = %to_commit, force = %force))] -pub fn reset( +pub fn push( repository: &Repository, repo_details: &RepoDetails, branch_name: BranchName, diff --git a/crates/server/src/actors/repo/branch.rs b/crates/server/src/actors/repo/branch.rs index bab06f1d..0455e445 100644 --- a/crates/server/src/actors/repo/branch.rs +++ b/crates/server/src/actors/repo/branch.rs @@ -36,7 +36,7 @@ pub async fn advance_next( &repository, repo_config.branches().next(), commit.into(), - git::reset::Force::No, + git::push::Force::No, ) { warn!(?err, "Failed") } @@ -91,7 +91,7 @@ pub async fn advance_main( &repository, repo_config.branches().main(), next.into(), - git::reset::Force::No, + git::push::Force::No, ) { warn!(?err, "Failed") }; diff --git a/crates/server/src/gitforge/forgejo/branch/validate_positions.rs b/crates/server/src/gitforge/forgejo/branch/validate_positions.rs index e3abfb9e..baca4612 100644 --- a/crates/server/src/gitforge/forgejo/branch/validate_positions.rs +++ b/crates/server/src/gitforge/forgejo/branch/validate_positions.rs @@ -77,7 +77,7 @@ pub async fn validate_positions( repository, repo_config.branches().next(), main.into(), - git::reset::Force::From(next.clone().into()), + git::push::Force::From(next.clone().into()), ) { warn!(?err, "Failed to reset next to main"); return Err(Error::FailedToResetBranch { @@ -103,7 +103,7 @@ pub async fn validate_positions( repository, repo_config.branches().next(), main.into(), - git::reset::Force::From(next.clone().into()), + git::push::Force::From(next.clone().into()), ) { warn!(?err, "Failed to reset next to main"); return Err(Error::FailedToResetBranch { diff --git a/crates/server/src/gitforge/forgejo/mod.rs b/crates/server/src/gitforge/forgejo/mod.rs index 764e1a5a..ef7a7fad 100644 --- a/crates/server/src/gitforge/forgejo/mod.rs +++ b/crates/server/src/gitforge/forgejo/mod.rs @@ -74,10 +74,10 @@ impl super::ForgeLike for ForgeJoEnv { repository: &git::Repository, branch_name: BranchName, to_commit: GitRef, - force: git::reset::Force, - ) -> git::reset::Result { + force: git::push::Force, + ) -> git::push::Result { git::fetch(repository, &self.repo_details)?; - git::reset( + git::push( repository, &self.repo_details, branch_name, diff --git a/crates/server/src/gitforge/mock_forge.rs b/crates/server/src/gitforge/mock_forge.rs index e3ab3f53..830e85e1 100644 --- a/crates/server/src/gitforge/mock_forge.rs +++ b/crates/server/src/gitforge/mock_forge.rs @@ -44,8 +44,8 @@ impl super::ForgeLike for MockForgeEnv { _repository: &Repository, _branch_name: BranchName, _to_commit: GitRef, - _force: git::reset::Force, - ) -> git::reset::Result { + _force: git::push::Force, + ) -> git::push::Result { todo!() } diff --git a/crates/server/src/gitforge/mod.rs b/crates/server/src/gitforge/mod.rs index c5630380..824f84fc 100644 --- a/crates/server/src/gitforge/mod.rs +++ b/crates/server/src/gitforge/mod.rs @@ -50,8 +50,8 @@ pub trait ForgeLike { repository: &Repository, branch_name: BranchName, to_commit: GitRef, - force: git::reset::Force, - ) -> git::reset::Result; + force: git::push::Force, + ) -> git::push::Result; /// Checks the results of any (e.g. CI) status checks for the commit. async fn commit_status(&self, commit: &git::Commit) -> CommitStatus;