Skip to content

Commit 727fb95

Browse files
committed
version 0.2.1
1 parent 43e2926 commit 727fb95

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "codeowners"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55

66
[profile.release]

src/ownership/validator.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,18 @@ impl Error {
174174
match self {
175175
Error::FileWithoutOwner { path } => vec![format!("- {}", path.to_string_lossy())],
176176
Error::FileWithMultipleOwners { path, owners } => {
177-
let mut output = vec![format!("\n{}", path.to_string_lossy().to_string())];
178-
for owner in owners.iter().sorted_by_key(|owner| owner.team_name.to_lowercase()) {
179-
output.push(format!(" owner: {}", owner.team_name));
180-
for source in &owner.sources {
181-
output.push(format!(" - {}", source));
182-
}
183-
}
184-
vec![output.join("\n")]
177+
let path_display = path.to_string_lossy();
178+
let mut messages = vec![format!("\n{path_display}")];
179+
180+
owners
181+
.iter()
182+
.sorted_by_key(|owner| owner.team_name.to_lowercase())
183+
.for_each(|owner| {
184+
messages.push(format!(" owner: {}", owner.team_name));
185+
messages.extend(owner.sources.iter().map(|source| format!(" - {source}")));
186+
});
187+
188+
vec![messages.join("\n")]
185189
}
186190
Error::CodeownershipFileIsStale => vec![],
187191
Error::InvalidTeam { name, path } => vec![format!("- {} is referencing an invalid team - '{}'", path.to_string_lossy(), name)],

tests/invalid_project_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,4 @@ fn test_for_file_multiple_owners() -> Result<(), Box<dyn Error>> {
7979
- Owner specified in `ruby/app/services/.codeowner`
8080
"}));
8181
Ok(())
82-
}
82+
}

tests/valid_project_test.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ fn test_for_file() -> Result<(), Box<dyn Error>> {
4646
.stdout(predicate::eq(indoc! {"
4747
Team: Payroll
4848
Team YML: config/teams/payroll.yml
49-
Description: Owner annotation at the top of the file
49+
Description:
50+
- Owner annotation at the top of the file
5051
"}));
5152
Ok(())
5253
}

0 commit comments

Comments
 (0)