From 446300e7869a154a83aa2a82cc18529db035c163 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 16 May 2024 14:45:25 +0100 Subject: [PATCH] refactor(git): rename reset as push --- Cargo.toml | 4 +++- crates/git/src/lib.rs | 4 ++-- crates/git/src/{reset.rs => push.rs} | 2 +- crates/server/src/actors/repo/branch.rs | 4 ++-- .../src/gitforge/forgejo/branch/validate_positions.rs | 4 ++-- crates/server/src/gitforge/forgejo/mod.rs | 6 +++--- crates/server/src/gitforge/mock_forge.rs | 4 ++-- crates/server/src/gitforge/mod.rs | 4 ++-- 8 files changed, 17 insertions(+), 15 deletions(-) rename crates/git/src/{reset.rs => push.rs} (99%) diff --git a/Cargo.toml b/Cargo.toml index 8e82fab..5085fa5 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 b4627df..1fea917 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 5d3f0bb..c4a506a 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 bab06f1..0455e44 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 e3abfb9..baca461 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 764e1a5..ef7a7fa 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 e3ab3f5..830e85e 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 c563038..824f84f 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;