Skip to content

Commit 913dbd0

Browse files
committed
remove caching, which makes seemingly no speed difference
it seems liek this might be due to the file stat call needed on each file which is equivalent to just reading the 1st line of each file.
1 parent 41462b2 commit 913dbd0

19 files changed

Lines changed: 24 additions & 408 deletions

src/cache/file.rs

Lines changed: 0 additions & 179 deletions
This file was deleted.

src/cache/mod.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/cache/noop.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/cli.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ struct Args {
7575
/// Path for the root of the project
7676
#[arg(long, default_value = ".")]
7777
project_root: PathBuf,
78-
79-
/// Run without the cache (good for CI, testing)
80-
#[arg(long)]
81-
no_cache: bool,
8278
}
8379

8480
impl Args {
@@ -113,7 +109,6 @@ pub fn cli() -> Result<RunResult, RunnerError> {
113109
config_path,
114110
codeowners_file_path,
115111
project_root,
116-
no_cache: args.no_cache,
117112
};
118113

119114
let runner_result = match args.command {

src/common_test.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ pub mod tests {
1010

1111
use tempfile::tempdir;
1212

13-
use crate::{
14-
cache::{Cache, noop::NoopCache},
15-
config::Config,
16-
ownership::Ownership,
17-
project_builder::ProjectBuilder,
18-
};
13+
use crate::{config::Config, ownership::Ownership, project_builder::ProjectBuilder};
1914

2015
macro_rules! ownership {
2116
($($test_files:expr),+) => {{
@@ -115,15 +110,14 @@ pub mod tests {
115110
let config: Config = serde_yaml::from_reader(config_file)?;
116111

117112
let codeowners_file_path = &test_config.temp_dir_path.join(".github/CODEOWNERS");
118-
let cache: Cache = NoopCache::default().into();
119-
let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone(), &cache);
113+
let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone());
120114
let project = builder.build()?;
121115
let ownership = Ownership::build(project);
122116
if test_config.generate_codeowners {
123117
std::fs::write(codeowners_file_path, ownership.generate_file())?;
124118
}
125119
// rebuild project to ensure new codeowners file is read
126-
let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone(), &cache);
120+
let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone());
127121
let project = builder.build()?;
128122
Ok(Ownership::build(project))
129123
}

src/crosscheck.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
use std::path::Path;
22

33
use crate::{
4-
cache::Cache,
54
config::Config,
65
ownership::file_owner_resolver::find_file_owners,
76
project::Project,
87
project_builder::ProjectBuilder,
98
runner::{RunConfig, RunResult, config_from_path, team_for_file_from_codeowners},
109
};
1110

12-
pub fn crosscheck_owners(run_config: &RunConfig, cache: &Cache) -> RunResult {
13-
match do_crosscheck_owners(run_config, cache) {
11+
pub fn crosscheck_owners(run_config: &RunConfig) -> RunResult {
12+
match do_crosscheck_owners(run_config) {
1413
Ok(mismatches) if mismatches.is_empty() => RunResult {
1514
info_messages: vec!["Success! All files match between CODEOWNERS and for-file command.".to_string()],
1615
..Default::default()
@@ -26,9 +25,9 @@ pub fn crosscheck_owners(run_config: &RunConfig, cache: &Cache) -> RunResult {
2625
}
2726
}
2827

29-
fn do_crosscheck_owners(run_config: &RunConfig, cache: &Cache) -> Result<Vec<String>, String> {
28+
fn do_crosscheck_owners(run_config: &RunConfig) -> Result<Vec<String>, String> {
3029
let config = load_config(run_config)?;
31-
let project = build_project(&config, run_config, cache)?;
30+
let project = build_project(&config, run_config)?;
3231

3332
let mut mismatches: Vec<String> = Vec::new();
3433
for file in &project.files {
@@ -46,13 +45,8 @@ fn load_config(run_config: &RunConfig) -> Result<Config, String> {
4645
config_from_path(&run_config.config_path).map_err(|e| e.to_string())
4746
}
4847

49-
fn build_project(config: &Config, run_config: &RunConfig, cache: &Cache) -> Result<Project, String> {
50-
let mut project_builder = ProjectBuilder::new(
51-
config,
52-
run_config.project_root.clone(),
53-
run_config.codeowners_file_path.clone(),
54-
cache,
55-
);
48+
fn build_project(config: &Config, run_config: &RunConfig) -> Result<Project, String> {
49+
let mut project_builder = ProjectBuilder::new(config, run_config.project_root.clone(), run_config.codeowners_file_path.clone());
5650
project_builder.build().map_err(|e| e.to_string())
5751
}
5852

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
pub mod cache;
21
pub(crate) mod common_test;
32
pub mod config;
43
pub mod crosscheck;
54
pub mod ownership;
65
pub mod path_utils;
76
pub(crate) mod project;
87
pub mod project_builder;
9-
pub mod project_file_builder;
8+
pub(crate) mod project_file_builder;
109
pub mod runner;
1110
pub(crate) mod tracked_files;

src/ownership/file_owner_resolver.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
use fast_glob::glob_match;
88
use glob::glob;
99

10-
use crate::{config::Config, project::Team, project_file_builder::build_project_file_without_cache};
10+
use crate::{config::Config, project::Team, project_file_builder::build_project_file};
1111

1212
use super::{FileOwner, mapper::Source};
1313

@@ -126,12 +126,8 @@ fn load_teams(project_root: &Path, team_file_globs: &[String]) -> std::result::R
126126
}
127127

128128
fn read_top_of_file_team(path: &Path) -> Option<String> {
129-
let project_file = build_project_file_without_cache(&path.to_path_buf());
130-
if let Some(owner) = project_file.owner {
131-
return Some(owner);
132-
}
133-
134-
None
129+
let project_file = build_project_file(&path.to_path_buf());
130+
project_file.owner
135131
}
136132

137133
fn most_specific_directory_owner(

0 commit comments

Comments
 (0)