Skip to content

Commit 8893ed3

Browse files
committed
mentioning code_ownership in readme
1 parent 5deeb8b commit 8893ed3

File tree

2 files changed

+28
-34
lines changed

2 files changed

+28
-34
lines changed

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Codeowners
22

3-
**Codeowners** is a fast, Rust-based CLI for generating and validating [GitHub `CODEOWNERS` files](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) in large repositories. It supports conventions for Ruby and JavaScript projects, and is a high-performance reimplementation of the [original Ruby CLI](https://github.com/rubyatscale/code_ownership).
3+
**Codeowners** is a fast, Rust-based CLI for generating and validating [GitHub `CODEOWNERS` files](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) in large repositories.
4+
5+
Note: For Ruby application, it's usually easier to use `codeowners-rs` via the [code_ownership](https://github.com/rubyatscale/code_ownership) gem.
46

57
## 🚀 Quick Start: Generate & Validate
68

@@ -15,20 +17,6 @@ codeowners gv
1517
- Validate that all files are properly owned and that the file is up to date
1618
- Exit with a nonzero code and detailed errors if validation fails
1719

18-
**Why use this tool?**
19-
On large projects, `codeowners gv` is _over 10x faster_ than the legacy Ruby implementation:
20-
21-
```
22-
$ hyperfine 'codeownership validate' 'codeowners validate'
23-
Benchmark 1: codeownership validate (ruby gem)
24-
Time (mean ± σ): 47.991 s ± 1.220 s
25-
Benchmark 2: codeowners gv (this repo)
26-
Time (mean ± σ): 4.263 s ± 0.025 s
27-
28-
Summary
29-
codeowners gv ran 11.26 ± 0.29 times faster than codeownership validate
30-
```
31-
3220
## Table of Contents
3321

3422
- [Quick Start: Generate & Validate](#-quick-start-generate--validate)

src/runner.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ pub fn team_for_file(run_config: &RunConfig, file_path: &str) -> Result<Option<T
5656
Ok(owners.first().map(|fo| fo.team.clone()))
5757
}
5858

59-
6059
pub fn version() -> String {
6160
env!("CARGO_PKG_VERSION").to_string()
6261
}
@@ -258,7 +257,6 @@ impl Runner {
258257
}
259258
}
260259

261-
262260
fn for_file_codeowners_only(run_config: &RunConfig, file_path: &str) -> RunResult {
263261
match team_for_file_from_codeowners(run_config, file_path) {
264262
Ok(Some(team)) => {
@@ -362,12 +360,20 @@ mod tests {
362360
#[test]
363361
fn test_file_owners_for_file() {
364362
let temp_dir = tempdir().unwrap();
365-
write_file(&temp_dir.path(), "config/code_ownership.yml", &common_test::tests::DEFAULT_CODE_OWNERSHIP_YML);
363+
write_file(
364+
temp_dir.path(),
365+
"config/code_ownership.yml",
366+
common_test::tests::DEFAULT_CODE_OWNERSHIP_YML,
367+
);
366368
["a", "b", "c"].iter().for_each(|name| {
367369
let team_yml = format!("name: {}\ngithub:\n team: \"@{}\"\n members:\n - {}member\n", name, name, name);
368-
write_file(&temp_dir.path(), &format!("config/teams/{}.yml", name), &team_yml);
370+
write_file(temp_dir.path(), &format!("config/teams/{}.yml", name), &team_yml);
369371
});
370-
write_file(&temp_dir.path(), "app/consumers/deep/nesting/nestdir/deep_file.rb", "# @team b\nclass DeepFile end;");
372+
write_file(
373+
temp_dir.path(),
374+
"app/consumers/deep/nesting/nestdir/deep_file.rb",
375+
"# @team b\nclass DeepFile end;",
376+
);
371377

372378
let run_config = RunConfig {
373379
project_root: temp_dir.path().to_path_buf(),
@@ -376,19 +382,19 @@ mod tests {
376382
no_cache: false,
377383
};
378384

379-
380-
let file_owners = file_owners_for_file(&run_config, "app/consumers/deep/nesting/nestdir/deep_file.rb").unwrap();
381-
assert_eq!(file_owners.len(), 1);
382-
assert_eq!(file_owners[0].team.name, "b");
383-
assert_eq!(file_owners[0].team.github_team, "@b");
384-
assert_eq!(file_owners[0].team.path.to_string_lossy().ends_with("config/teams/b.yml"), true);
385-
assert_eq!(file_owners[0].sources.len(), 1);
386-
assert_eq!(file_owners[0].sources, vec![Source::AnnotatedFile]);
387-
388-
389-
let team = team_for_file(&run_config, "app/consumers/deep/nesting/nestdir/deep_file.rb").unwrap().unwrap();
390-
assert_eq!(team.name, "b");
391-
assert_eq!(team.github_team, "@b");
392-
assert_eq!(team.path.to_string_lossy().ends_with("config/teams/b.yml"), true);
385+
let file_owners = file_owners_for_file(&run_config, "app/consumers/deep/nesting/nestdir/deep_file.rb").unwrap();
386+
assert_eq!(file_owners.len(), 1);
387+
assert_eq!(file_owners[0].team.name, "b");
388+
assert_eq!(file_owners[0].team.github_team, "@b");
389+
assert!(file_owners[0].team.path.to_string_lossy().ends_with("config/teams/b.yml"));
390+
assert_eq!(file_owners[0].sources.len(), 1);
391+
assert_eq!(file_owners[0].sources, vec![Source::AnnotatedFile]);
392+
393+
let team = team_for_file(&run_config, "app/consumers/deep/nesting/nestdir/deep_file.rb")
394+
.unwrap()
395+
.unwrap();
396+
assert_eq!(team.name, "b");
397+
assert_eq!(team.github_team, "@b");
398+
assert!(team.path.to_string_lossy().ends_with("config/teams/b.yml"));
393399
}
394400
}

0 commit comments

Comments
 (0)