Skip to content

Commit

Permalink
version 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
perryqh committed Nov 8, 2024
1 parent 43e2926 commit 727fb95
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "codeowners"
version = "0.2.0"
version = "0.2.1"
edition = "2021"

[profile.release]
Expand Down
20 changes: 12 additions & 8 deletions src/ownership/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,18 @@ impl Error {
match self {
Error::FileWithoutOwner { path } => vec![format!("- {}", path.to_string_lossy())],
Error::FileWithMultipleOwners { path, owners } => {
let mut output = vec![format!("\n{}", path.to_string_lossy().to_string())];
for owner in owners.iter().sorted_by_key(|owner| owner.team_name.to_lowercase()) {
output.push(format!(" owner: {}", owner.team_name));
for source in &owner.sources {
output.push(format!(" - {}", source));
}
}
vec![output.join("\n")]
let path_display = path.to_string_lossy();
let mut messages = vec![format!("\n{path_display}")];

owners
.iter()
.sorted_by_key(|owner| owner.team_name.to_lowercase())
.for_each(|owner| {
messages.push(format!(" owner: {}", owner.team_name));
messages.extend(owner.sources.iter().map(|source| format!(" - {source}")));
});

vec![messages.join("\n")]
}
Error::CodeownershipFileIsStale => vec![],
Error::InvalidTeam { name, path } => vec![format!("- {} is referencing an invalid team - '{}'", path.to_string_lossy(), name)],
Expand Down
2 changes: 1 addition & 1 deletion tests/invalid_project_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ fn test_for_file_multiple_owners() -> Result<(), Box<dyn Error>> {
- Owner specified in `ruby/app/services/.codeowner`
"}));
Ok(())
}
}
3 changes: 2 additions & 1 deletion tests/valid_project_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ fn test_for_file() -> Result<(), Box<dyn Error>> {
.stdout(predicate::eq(indoc! {"
Team: Payroll
Team YML: config/teams/payroll.yml
Description: Owner annotation at the top of the file
Description:
- Owner annotation at the top of the file
"}));
Ok(())
}
Expand Down

0 comments on commit 727fb95

Please sign in to comment.