fix: use configured branch names in user notification
All checks were successful
Rust / build (push) Successful in 7m19s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 1m41s
All checks were successful
Rust / build (push) Successful in 7m19s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 1m41s
Remove near-duplicate to string implementations.
This commit is contained in:
parent
853b862f10
commit
4160b6d6ee
2 changed files with 33 additions and 29 deletions
|
@ -30,34 +30,8 @@ impl Actor for AlertsActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn short_message(user_notification: &UserNotification) -> String {
|
fn short_message(user_notification: &UserNotification) -> String {
|
||||||
let tail = match user_notification {
|
let (forge_alias, repo_alias) = user_notification.aliases();
|
||||||
UserNotification::CICheckFailed {
|
format!("[git-next] {forge_alias}/{repo_alias}: {user_notification}")
|
||||||
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}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn full_message(user_notification: &UserNotification) -> String {
|
fn full_message(user_notification: &UserNotification) -> String {
|
||||||
|
|
|
@ -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 {
|
impl Display for UserNotification {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
@ -127,7 +153,11 @@ impl Display for UserNotification {
|
||||||
Self::WebhookRegistration { reason, .. } => {
|
Self::WebhookRegistration { reason, .. } => {
|
||||||
format!("Failed to register webhook: {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}")
|
write!(f, "{message}")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue