Deduplicate common username/group prefixes in error msg
Some checks failed
Build / check (push) Failing after 5m20s
Build / build (push) Successful in 12m54s
Build / docs (push) Successful in 16m35s

This commit is contained in:
2025-11-10 00:50:36 +09:00
parent e8b28f5116
commit 46c5d372b2

View File

@@ -75,11 +75,13 @@ impl OwnerValidationError {
pub fn to_error_message(self, name: &str, db_or_user: DbOrUser) -> String {
let user = UnixUser::from_enviroment();
let UnixUser { username, groups } = user.unwrap_or(UnixUser {
let UnixUser { username, mut groups } = user.unwrap_or(UnixUser {
username: "???".to_string(),
groups: vec![],
});
groups.sort();
match self {
OwnerValidationError::NoMatch => format!(
indoc! {r#"
@@ -97,9 +99,9 @@ impl OwnerValidationError {
db_or_user.lowercased(),
username,
groups
.iter()
.into_iter()
.filter(|g| g != &username)
.map(|g| format!(" - {}", g))
.sorted()
.join("\n"),
)
.to_owned(),