From ba67b1ebcba46308a44d3f6dccc16ed8b0acefe3 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 16 Jul 2024 20:00:29 +0100 Subject: [PATCH] refactor: flag internally that dev not based on main will require used intervention Preparation for when we will be sending user notifications --- crates/git/src/validation/positions.rs | 5 ++++- crates/git/src/validation/tests.rs | 2 +- crates/repo-actor/src/handlers/validate_repo.rs | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/git/src/validation/positions.rs b/crates/git/src/validation/positions.rs index 689a56d7..ff60e2d9 100644 --- a/crates/git/src/validation/positions.rs +++ b/crates/git/src/validation/positions.rs @@ -40,7 +40,7 @@ pub fn validate_positions( // Validations: // Dev must be on main branch, else the USER must rebase it if is_not_based_on(&commit_histories.dev, &main) { - return Err(Error::NonRetryable(format!( + return Err(Error::UserIntervention(format!( "Branch '{}' not based on '{}'", dev_branch, main_branch ))); @@ -119,6 +119,9 @@ pub enum Error { #[error("{0} - not retrying")] NonRetryable(String), + + #[error("{0} - user intervention required")] + UserIntervention(String), } impl From for Error { fn from(value: git::fetch::Error) -> Self { diff --git a/crates/git/src/validation/tests.rs b/crates/git/src/validation/tests.rs index d4a236b9..4430fdd3 100644 --- a/crates/git/src/validation/tests.rs +++ b/crates/git/src/validation/tests.rs @@ -249,7 +249,7 @@ mod positions { //then assert!(matches!( err, - git::validation::positions::Error::NonRetryable(_) + git::validation::positions::Error::UserIntervention(_) )); } diff --git a/crates/repo-actor/src/handlers/validate_repo.rs b/crates/repo-actor/src/handlers/validate_repo.rs index e085bf73..a2bb08f9 100644 --- a/crates/repo-actor/src/handlers/validate_repo.rs +++ b/crates/repo-actor/src/handlers/validate_repo.rs @@ -97,7 +97,8 @@ impl Handler for actor::RepoActor { .into_actor(self) .wait(ctx); } - Err(git::validation::positions::Error::NonRetryable(message)) => { + Err(git::validation::positions::Error::NonRetryable(message)) + | Err(git::validation::positions::Error::UserIntervention(message)) => { actor::logger(&self.log, message); } }