Deduplicate common username/group prefixes in error msg
This commit is contained in:
@@ -75,11 +75,13 @@ impl OwnerValidationError {
|
|||||||
pub fn to_error_message(self, name: &str, db_or_user: DbOrUser) -> String {
|
pub fn to_error_message(self, name: &str, db_or_user: DbOrUser) -> String {
|
||||||
let user = UnixUser::from_enviroment();
|
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(),
|
username: "???".to_string(),
|
||||||
groups: vec![],
|
groups: vec![],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
groups.sort();
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
OwnerValidationError::NoMatch => format!(
|
OwnerValidationError::NoMatch => format!(
|
||||||
indoc! {r#"
|
indoc! {r#"
|
||||||
@@ -97,9 +99,9 @@ impl OwnerValidationError {
|
|||||||
db_or_user.lowercased(),
|
db_or_user.lowercased(),
|
||||||
username,
|
username,
|
||||||
groups
|
groups
|
||||||
.iter()
|
.into_iter()
|
||||||
|
.filter(|g| g != &username)
|
||||||
.map(|g| format!(" - {}", g))
|
.map(|g| format!(" - {}", g))
|
||||||
.sorted()
|
|
||||||
.join("\n"),
|
.join("\n"),
|
||||||
)
|
)
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
|
|||||||
Reference in New Issue
Block a user