diff --git a/crates/cli/src/alerts/mod.rs b/crates/cli/src/alerts/mod.rs index dac5f408..8e5db22c 100644 --- a/crates/cli/src/alerts/mod.rs +++ b/crates/cli/src/alerts/mod.rs @@ -30,34 +30,8 @@ impl Actor for AlertsActor { } fn short_message(user_notification: &UserNotification) -> String { - let tail = match user_notification { - UserNotification::CICheckFailed { - forge_alias, - repo_alias, - commit, - log: _, - } => format!("{forge_alias}/{repo_alias}: CI Check Failed: {commit}"), - UserNotification::RepoConfigLoadFailure { - forge_alias, - repo_alias, - reason: _, - } => format!("{forge_alias}/{repo_alias}: Invalid Repo Config"), - UserNotification::WebhookRegistration { - forge_alias, - repo_alias, - reason: _, - } => format!("{forge_alias}/{repo_alias}: Failed Webhook Registration"), - UserNotification::DevNotBasedOnMain { - forge_alias, - repo_alias, - dev_branch: _, - main_branch: _, - dev_commit: _, - main_commit: _, - log: _, - } => format!("{forge_alias}/{repo_alias}: Dev not based on Main"), - }; - format!("[git-next] {tail}") + let (forge_alias, repo_alias) = user_notification.aliases(); + format!("[git-next] {forge_alias}/{repo_alias}: {user_notification}") } fn full_message(user_notification: &UserNotification) -> String { diff --git a/crates/core/src/git/user_notification.rs b/crates/core/src/git/user_notification.rs index 828aea3e..cb29c664 100644 --- a/crates/core/src/git/user_notification.rs +++ b/crates/core/src/git/user_notification.rs @@ -116,6 +116,32 @@ impl UserNotification { }), } } + + #[must_use] + pub fn aliases(&self) -> (ForgeAlias, RepoAlias) { + match self { + Self::CICheckFailed { + forge_alias, + repo_alias, + .. + } + | Self::RepoConfigLoadFailure { + forge_alias, + repo_alias, + .. + } + | Self::WebhookRegistration { + forge_alias, + repo_alias, + .. + } + | Self::DevNotBasedOnMain { + forge_alias, + repo_alias, + .. + } => (forge_alias.clone(), repo_alias.clone()), + } + } } impl Display for UserNotification { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -127,7 +153,11 @@ impl Display for UserNotification { Self::WebhookRegistration { reason, .. } => { format!("Failed to register webhook: {reason}") } - Self::DevNotBasedOnMain { .. } => "Dev not based on main".to_string(), + Self::DevNotBasedOnMain { + dev_branch, + main_branch, + .. + } => format!("{dev_branch} not based on {main_branch}"), }; write!(f, "{message}") }