From 41462b2e2b673f2fc8b0545a013f784e445034ed Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Tue, 21 Oct 2025 21:04:47 -0700 Subject: [PATCH 1/2] read only the first line of a file for owner annotation --- src/project_file_builder.rs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/project_file_builder.rs b/src/project_file_builder.rs index 2c74c93..dc99d85 100644 --- a/src/project_file_builder.rs +++ b/src/project_file_builder.rs @@ -1,6 +1,8 @@ use error_stack::Result; use lazy_static::lazy_static; use regex::Regex; +use std::fs::File; +use std::io::{BufRead, BufReader}; use std::path::{Path, PathBuf}; use crate::{ @@ -49,8 +51,8 @@ impl<'a> ProjectFileBuilder<'a> { } pub(crate) fn build_project_file_without_cache(path: &PathBuf) -> ProjectFile { - let content = match std::fs::read_to_string(path) { - Ok(content) => content, + let file = match File::open(path) { + Ok(file) => file, Err(_) => { return ProjectFile { path: path.clone(), @@ -59,13 +61,21 @@ pub(crate) fn build_project_file_without_cache(path: &PathBuf) -> ProjectFile { } }; - let first_line = content.lines().next(); - let Some(first_line) = first_line else { - return ProjectFile { - path: path.clone(), - owner: None, - }; - }; + let mut reader = BufReader::new(file); + let mut first_line = String::with_capacity(256); + + match reader.read_line(&mut first_line) { + Ok(0) | Err(_) => { + return ProjectFile { + path: path.clone(), + owner: None, + }; + } + Ok(_) => {} + } + + // read_line includes the newline, but .lines() doesn't, so we need to trim + let first_line = first_line.trim_end(); let owner = TEAM_REGEX .captures(first_line) From 913dbd0947e10f60dd96912d1246b3f6e22455d7 Mon Sep 17 00:00:00 2001 From: Martin Emde Date: Wed, 22 Oct 2025 10:59:24 -0700 Subject: [PATCH 2/2] 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. --- src/cache/file.rs | 179 --------------------------- src/cache/mod.rs | 29 ----- src/cache/noop.rs | 26 ---- src/cli.rs | 5 - src/common_test.rs | 12 +- src/crosscheck.rs | 18 +-- src/lib.rs | 3 +- src/ownership/file_owner_resolver.rs | 10 +- src/project_builder.rs | 10 +- src/project_file_builder.rs | 45 +------ src/runner.rs | 41 +----- src/runner/types.rs | 1 - tests/cache_test.rs | 29 ----- tests/common/mod.rs | 3 +- tests/crosscheck_owners_test.rs | 2 - tests/runner_api.rs | 4 - tests/untracked_files_test.rs | 2 - tests/valid_project_test.rs | 10 -- tests/validate_files_test.rs | 3 - 19 files changed, 24 insertions(+), 408 deletions(-) delete mode 100644 src/cache/file.rs delete mode 100644 src/cache/mod.rs delete mode 100644 src/cache/noop.rs delete mode 100644 tests/cache_test.rs diff --git a/src/cache/file.rs b/src/cache/file.rs deleted file mode 100644 index 4132ab8..0000000 --- a/src/cache/file.rs +++ /dev/null @@ -1,179 +0,0 @@ -use crate::project::Error; -use error_stack::{Result, ResultExt}; -use std::{ - collections::HashMap, - fs::{self, File, OpenOptions}, - io::{BufReader, BufWriter}, - path::{Path, PathBuf}, - sync::Mutex, -}; - -use super::{Caching, FileOwnerCacheEntry}; - -#[derive(Debug)] -pub struct GlobalCache { - base_path: PathBuf, - cache_directory: String, - file_owner_cache: Option>>>, -} - -const DEFAULT_CACHE_CAPACITY: usize = 50000; - -impl Caching for GlobalCache { - fn get_file_owner(&self, path: &Path) -> Result, Error> { - if let Some(cache_mutex) = self.file_owner_cache.as_ref() - && let Ok(cache) = cache_mutex.lock() - && let Some(cached_entry) = cache.get(path) - { - let timestamp = get_file_timestamp(path)?; - if cached_entry.timestamp == timestamp { - return Ok(Some(cached_entry.clone())); - } - } - Ok(None) - } - - fn write_file_owner(&self, path: &Path, owner: Option) { - if let Some(cache_mutex) = self.file_owner_cache.as_ref() - && let Ok(mut cache) = cache_mutex.lock() - && let Ok(timestamp) = get_file_timestamp(path) - { - cache.insert(path.to_path_buf(), FileOwnerCacheEntry { timestamp, owner }); - } - } - - fn persist_cache(&self) -> Result<(), Error> { - let cache_path = self.get_cache_path(); - let file = OpenOptions::new() - .write(true) - .create(true) - .truncate(true) - .open(cache_path) - .change_context(Error::Io)?; - - let writer = BufWriter::new(file); - if let Some(cache_mutex) = self.file_owner_cache.as_ref() { - let cache = cache_mutex.lock().map_err(|_| Error::Io)?; - serde_json::to_writer(writer, &*cache).change_context(Error::SerdeJson) - } else { - Ok(()) - } - } - - fn delete_cache(&self) -> Result<(), Error> { - let cache_path = self.get_cache_path(); - tracing::debug!("Deleting cache file: {}", cache_path.display()); - fs::remove_file(cache_path).change_context(Error::Io) - } -} - -impl GlobalCache { - pub fn new(base_path: PathBuf, cache_directory: String) -> Result { - let mut cache = Self { - base_path, - cache_directory, - file_owner_cache: None, - }; - cache.load_cache().change_context(Error::Io)?; - Ok(cache) - } - - fn load_cache(&mut self) -> Result<(), Error> { - let cache_path = self.get_cache_path(); - if !cache_path.exists() { - self.file_owner_cache = Some(Box::new(Mutex::new(HashMap::with_capacity(DEFAULT_CACHE_CAPACITY)))); - return Ok(()); - } - - let file = File::open(cache_path).change_context(Error::Io)?; - let reader = BufReader::new(file); - let json = serde_json::from_reader(reader); - self.file_owner_cache = match json { - Ok(cache) => Some(Box::new(Mutex::new(cache))), - _ => Some(Box::new(Mutex::new(HashMap::with_capacity(DEFAULT_CACHE_CAPACITY)))), - }; - Ok(()) - } - - fn get_cache_path(&self) -> PathBuf { - let cache_dir = self.base_path.join(PathBuf::from(&self.cache_directory)); - let _ = fs::create_dir_all(&cache_dir); - - cache_dir.join("project-file-cache.json") - } -} -fn get_file_timestamp(path: &Path) -> Result { - let metadata = fs::metadata(path).change_context(Error::Io)?; - metadata - .modified() - .change_context(Error::Io)? - .duration_since(std::time::UNIX_EPOCH) - .change_context(Error::Io) - .map(|duration| duration.as_secs()) -} - -#[cfg(test)] -mod tests { - use tempfile::tempdir; - - use super::*; - - #[test] - fn test_cache_dir() -> Result<(), Error> { - let temp_dir = tempdir().change_context(Error::Io)?; - let cache_dir = "test-codeowners-cache"; - let cache = GlobalCache::new(temp_dir.path().to_path_buf(), cache_dir.to_owned())?; - - let file_path = PathBuf::from("tests/fixtures/valid_project/ruby/app/models/bank_account.rb"); - assert!(file_path.exists()); - let timestamp = get_file_timestamp(&file_path)?; - - let cache_entry = cache.get_file_owner(&file_path)?; - assert_eq!(cache_entry, None); - - cache.write_file_owner(&file_path, Some("owner 1".to_owned())); - let cache_entry = cache.get_file_owner(&file_path)?; - assert_eq!( - cache_entry, - Some(FileOwnerCacheEntry { - timestamp, - owner: Some("owner 1".to_owned()) - }) - ); - - cache.persist_cache().change_context(Error::Io)?; - let persisted_cache_path = cache.get_cache_path(); - assert!(persisted_cache_path.exists()); - - let cache = GlobalCache::new(temp_dir.path().to_path_buf(), cache_dir.to_owned())?; - let cache_entry = cache.get_file_owner(&file_path)?; - assert_eq!( - cache_entry, - Some(FileOwnerCacheEntry { - timestamp, - owner: Some("owner 1".to_owned()) - }) - ); - - cache.delete_cache().change_context(Error::Io)?; - assert!(!persisted_cache_path.exists()); - - Ok(()) - } - - #[test] - fn test_corrupted_cache() -> Result<(), Error> { - let temp_dir = tempdir().change_context(Error::Io)?; - let cache_dir = "test-codeowners-cache"; - let cache = GlobalCache::new(temp_dir.path().to_path_buf(), cache_dir.to_owned())?; - let cache_path = cache.get_cache_path(); - fs::write(cache_path, "corrupted_cache").change_context(Error::Io)?; - - // When the cache is corrupted, it should be ignored and a new cache should be created - let cache = GlobalCache::new(temp_dir.path().to_path_buf(), cache_dir.to_owned())?; - let file_path = PathBuf::from("tests/fixtures/valid_project/ruby/app/models/bank_account.rb"); - let cache_entry = cache.get_file_owner(&file_path)?; - assert_eq!(cache_entry, None); - Ok(()) - } -} diff --git a/src/cache/mod.rs b/src/cache/mod.rs deleted file mode 100644 index 4406a26..0000000 --- a/src/cache/mod.rs +++ /dev/null @@ -1,29 +0,0 @@ -use crate::project::Error; -use enum_dispatch::enum_dispatch; -use error_stack::Result; -use file::GlobalCache; -use noop::NoopCache; -use std::path::Path; - -pub mod file; -pub mod noop; - -#[enum_dispatch] -pub enum Cache { - GlobalCache, - NoopCache, -} - -#[enum_dispatch(Cache)] -pub trait Caching { - fn get_file_owner(&self, path: &Path) -> Result, Error>; - fn write_file_owner(&self, path: &Path, owner: Option); - fn persist_cache(&self) -> Result<(), Error>; - fn delete_cache(&self) -> Result<(), Error>; -} - -#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq)] -pub struct FileOwnerCacheEntry { - timestamp: u64, - pub owner: Option, -} diff --git a/src/cache/noop.rs b/src/cache/noop.rs deleted file mode 100644 index 4adc015..0000000 --- a/src/cache/noop.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::project::Error; -use error_stack::Result; -use std::path::Path; - -use super::{Caching, FileOwnerCacheEntry}; - -#[derive(Default)] -pub struct NoopCache {} - -impl Caching for NoopCache { - fn get_file_owner(&self, _path: &Path) -> Result, Error> { - Ok(None) - } - - fn write_file_owner(&self, _path: &Path, _owner: Option) { - // noop - } - - fn persist_cache(&self) -> Result<(), Error> { - Ok(()) - } - - fn delete_cache(&self) -> Result<(), Error> { - Ok(()) - } -} diff --git a/src/cli.rs b/src/cli.rs index cb56ac6..caa6953 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -75,10 +75,6 @@ struct Args { /// Path for the root of the project #[arg(long, default_value = ".")] project_root: PathBuf, - - /// Run without the cache (good for CI, testing) - #[arg(long)] - no_cache: bool, } impl Args { @@ -113,7 +109,6 @@ pub fn cli() -> Result { config_path, codeowners_file_path, project_root, - no_cache: args.no_cache, }; let runner_result = match args.command { diff --git a/src/common_test.rs b/src/common_test.rs index 57a8bd8..551d3f8 100644 --- a/src/common_test.rs +++ b/src/common_test.rs @@ -10,12 +10,7 @@ pub mod tests { use tempfile::tempdir; - use crate::{ - cache::{Cache, noop::NoopCache}, - config::Config, - ownership::Ownership, - project_builder::ProjectBuilder, - }; + use crate::{config::Config, ownership::Ownership, project_builder::ProjectBuilder}; macro_rules! ownership { ($($test_files:expr),+) => {{ @@ -115,15 +110,14 @@ pub mod tests { let config: Config = serde_yaml::from_reader(config_file)?; let codeowners_file_path = &test_config.temp_dir_path.join(".github/CODEOWNERS"); - let cache: Cache = NoopCache::default().into(); - let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone(), &cache); + let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone()); let project = builder.build()?; let ownership = Ownership::build(project); if test_config.generate_codeowners { std::fs::write(codeowners_file_path, ownership.generate_file())?; } // rebuild project to ensure new codeowners file is read - let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone(), &cache); + let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone()); let project = builder.build()?; Ok(Ownership::build(project)) } diff --git a/src/crosscheck.rs b/src/crosscheck.rs index b8e9405..325a383 100644 --- a/src/crosscheck.rs +++ b/src/crosscheck.rs @@ -1,7 +1,6 @@ use std::path::Path; use crate::{ - cache::Cache, config::Config, ownership::file_owner_resolver::find_file_owners, project::Project, @@ -9,8 +8,8 @@ use crate::{ runner::{RunConfig, RunResult, config_from_path, team_for_file_from_codeowners}, }; -pub fn crosscheck_owners(run_config: &RunConfig, cache: &Cache) -> RunResult { - match do_crosscheck_owners(run_config, cache) { +pub fn crosscheck_owners(run_config: &RunConfig) -> RunResult { + match do_crosscheck_owners(run_config) { Ok(mismatches) if mismatches.is_empty() => RunResult { info_messages: vec!["Success! All files match between CODEOWNERS and for-file command.".to_string()], ..Default::default() @@ -26,9 +25,9 @@ pub fn crosscheck_owners(run_config: &RunConfig, cache: &Cache) -> RunResult { } } -fn do_crosscheck_owners(run_config: &RunConfig, cache: &Cache) -> Result, String> { +fn do_crosscheck_owners(run_config: &RunConfig) -> Result, String> { let config = load_config(run_config)?; - let project = build_project(&config, run_config, cache)?; + let project = build_project(&config, run_config)?; let mut mismatches: Vec = Vec::new(); for file in &project.files { @@ -46,13 +45,8 @@ fn load_config(run_config: &RunConfig) -> Result { config_from_path(&run_config.config_path).map_err(|e| e.to_string()) } -fn build_project(config: &Config, run_config: &RunConfig, cache: &Cache) -> Result { - let mut project_builder = ProjectBuilder::new( - config, - run_config.project_root.clone(), - run_config.codeowners_file_path.clone(), - cache, - ); +fn build_project(config: &Config, run_config: &RunConfig) -> Result { + let mut project_builder = ProjectBuilder::new(config, run_config.project_root.clone(), run_config.codeowners_file_path.clone()); project_builder.build().map_err(|e| e.to_string()) } diff --git a/src/lib.rs b/src/lib.rs index 13d53a4..6cea8c7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -pub mod cache; pub(crate) mod common_test; pub mod config; pub mod crosscheck; @@ -6,6 +5,6 @@ pub mod ownership; pub mod path_utils; pub(crate) mod project; pub mod project_builder; -pub mod project_file_builder; +pub(crate) mod project_file_builder; pub mod runner; pub(crate) mod tracked_files; diff --git a/src/ownership/file_owner_resolver.rs b/src/ownership/file_owner_resolver.rs index cac884a..4426626 100644 --- a/src/ownership/file_owner_resolver.rs +++ b/src/ownership/file_owner_resolver.rs @@ -7,7 +7,7 @@ use std::{ use fast_glob::glob_match; use glob::glob; -use crate::{config::Config, project::Team, project_file_builder::build_project_file_without_cache}; +use crate::{config::Config, project::Team, project_file_builder::build_project_file}; use super::{FileOwner, mapper::Source}; @@ -126,12 +126,8 @@ fn load_teams(project_root: &Path, team_file_globs: &[String]) -> std::result::R } fn read_top_of_file_team(path: &Path) -> Option { - let project_file = build_project_file_without_cache(&path.to_path_buf()); - if let Some(owner) = project_file.owner { - return Some(owner); - } - - None + let project_file = build_project_file(&path.to_path_buf()); + project_file.owner } fn most_specific_directory_owner( diff --git a/src/project_builder.rs b/src/project_builder.rs index 1945b0a..5178a12 100644 --- a/src/project_builder.rs +++ b/src/project_builder.rs @@ -11,10 +11,9 @@ use rayon::iter::{IntoParallelIterator, ParallelIterator}; use tracing::{instrument, warn}; use crate::{ - cache::Cache, config::Config, project::{DirectoryCodeownersFile, Error, Package, PackageType, Project, ProjectFile, Team, VendoredGem, deserializers}, - project_file_builder::ProjectFileBuilder, + project_file_builder::build_project_file, tracked_files, }; @@ -36,16 +35,13 @@ pub struct ProjectBuilder<'a> { config: &'a Config, base_path: PathBuf, codeowners_file_path: PathBuf, - project_file_builder: ProjectFileBuilder<'a>, } const INITIAL_VECTOR_CAPACITY: usize = 1000; impl<'a> ProjectBuilder<'a> { - pub fn new(config: &'a Config, base_path: PathBuf, codeowners_file_path: PathBuf, cache: &'a Cache) -> Self { - let project_file_builder = ProjectFileBuilder::new(cache); + pub fn new(config: &'a Config, base_path: PathBuf, codeowners_file_path: PathBuf) -> Self { Self { - project_file_builder, config, base_path, codeowners_file_path, @@ -170,7 +166,7 @@ impl<'a> ProjectBuilder<'a> { Ok(EntryType::TeamFile(absolute_path.to_owned(), relative_path.to_owned())) } _ if matches_globs(&relative_path, &self.config.owned_globs) && !matches_globs(&relative_path, &self.config.unowned_globs) => { - let project_file = self.project_file_builder.build(absolute_path.to_path_buf()); + let project_file = build_project_file(&absolute_path.to_path_buf()); Ok(EntryType::OwnedFile(project_file)) } _ => Ok(EntryType::NullEntry()), diff --git a/src/project_file_builder.rs b/src/project_file_builder.rs index dc99d85..70d1ac4 100644 --- a/src/project_file_builder.rs +++ b/src/project_file_builder.rs @@ -1,56 +1,17 @@ -use error_stack::Result; use lazy_static::lazy_static; use regex::Regex; use std::fs::File; use std::io::{BufRead, BufReader}; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; -use crate::{ - cache::{Cache, Caching}, - project::{Error, ProjectFile}, -}; - -pub struct ProjectFileBuilder<'a> { - global_cache: &'a Cache, -} +use crate::project::ProjectFile; lazy_static! { static ref TEAM_REGEX: Regex = Regex::new(r#"^(?:#|//||%>)?$"#).expect("error compiling regular expression"); } -impl<'a> ProjectFileBuilder<'a> { - pub fn new(global_cache: &'a Cache) -> Self { - Self { global_cache } - } - - pub(crate) fn build(&self, path: PathBuf) -> ProjectFile { - if let Ok(Some(cached_project_file)) = self.get_project_file_from_cache(&path) { - return cached_project_file; - } - - let project_file = build_project_file_without_cache(&path); - - self.save_project_file_to_cache(&path, &project_file); - - project_file - } - - fn get_project_file_from_cache(&self, path: &Path) -> Result, Error> { - self.global_cache.get_file_owner(path).map(|entry| { - entry.map(|e| ProjectFile { - path: path.to_path_buf(), - owner: e.owner, - }) - }) - } - - fn save_project_file_to_cache(&self, path: &Path, project_file: &ProjectFile) { - self.global_cache.write_file_owner(path, project_file.owner.clone()); - } -} - -pub(crate) fn build_project_file_without_cache(path: &PathBuf) -> ProjectFile { +pub(crate) fn build_project_file(path: &PathBuf) -> ProjectFile { let file = match File::open(path) { Ok(file) => file, Err(_) => { diff --git a/src/runner.rs b/src/runner.rs index 4d64750..e4d36fe 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -4,7 +4,6 @@ use error_stack::{Result, ResultExt}; use serde::Serialize; use crate::{ - cache::{Cache, Caching, file::GlobalCache, noop::NoopCache}, config::Config, ownership::{FileOwner, Ownership}, project_builder::ProjectBuilder, @@ -18,7 +17,6 @@ pub use self::api::*; pub struct Runner { run_config: RunConfig, ownership: Ownership, - cache: Cache, config: Config, } @@ -54,39 +52,16 @@ impl Runner { pub fn new(run_config: &RunConfig) -> Result { let config = config_from_path(&run_config.config_path)?; - let cache: Cache = if run_config.no_cache { - NoopCache::default().into() - } else { - GlobalCache::new(run_config.project_root.clone(), config.cache_directory.clone()) - .change_context(Error::Io(format!( - "Can't create cache: {}", - &run_config.config_path.to_string_lossy() - ))) - .attach_printable(format!("Can't create cache: {}", &run_config.config_path.to_string_lossy()))? - .into() - }; - - let mut project_builder = ProjectBuilder::new( - &config, - run_config.project_root.clone(), - run_config.codeowners_file_path.clone(), - &cache, - ); + let mut project_builder = ProjectBuilder::new(&config, run_config.project_root.clone(), run_config.codeowners_file_path.clone()); let project = project_builder.build().change_context(Error::Io(format!( "Can't build project: {}", &run_config.config_path.to_string_lossy() )))?; let ownership = Ownership::build(project); - cache.persist_cache().change_context(Error::Io(format!( - "Can't persist cache: {}", - &run_config.config_path.to_string_lossy() - )))?; - Ok(Self { run_config: run_config.clone(), ownership, - cache, config, }) } @@ -202,20 +177,12 @@ impl Runner { } pub fn delete_cache(&self) -> RunResult { - match self.cache.delete_cache().change_context(Error::Io(format!( - "Can't delete cache: {}", - &self.run_config.config_path.to_string_lossy() - ))) { - Ok(_) => RunResult::default(), - Err(err) => RunResult { - io_errors: vec![err.to_string()], - ..Default::default() - }, - } + // Cache has been removed - this is now a no-op + RunResult::default() } pub fn crosscheck_owners(&self) -> RunResult { - crate::crosscheck::crosscheck_owners(&self.run_config, &self.cache) + crate::crosscheck::crosscheck_owners(&self.run_config) } pub fn owners_for_file(&self, file_path: &str) -> Result, Error> { diff --git a/src/runner/types.rs b/src/runner/types.rs index c42fa02..81c6a9b 100644 --- a/src/runner/types.rs +++ b/src/runner/types.rs @@ -16,7 +16,6 @@ pub struct RunConfig { pub project_root: PathBuf, pub codeowners_file_path: PathBuf, pub config_path: PathBuf, - pub no_cache: bool, } #[derive(Debug, Serialize)] diff --git a/tests/cache_test.rs b/tests/cache_test.rs deleted file mode 100644 index 7a1ba03..0000000 --- a/tests/cache_test.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::path::PathBuf; -use std::process::Command; - -use std::error::Error; - -use assert_cmd::assert::OutputAssertExt; -use assert_cmd::cargo::CommandCargoExt; - -mod common; - -#[test] -fn test_delete_cache() -> Result<(), Box> { - let cache_dir = PathBuf::from("tests/fixtures/valid_project/tmp/cache/codeowners"); - std::fs::create_dir_all(&cache_dir)?; - let cache_path = cache_dir.join("project-file-cache.json"); - std::fs::write(&cache_path, "dummy")?; - assert!(&cache_path.exists(), "Cache file was not created"); - - Command::cargo_bin("codeowners")? - .arg("--project-root") - .arg("tests/fixtures/valid_project") - .arg("delete-cache") - .assert() - .success(); - - assert!(!&cache_path.exists(), "Cache file was not deleted"); - common::teardown(); - Ok(()) -} diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 226e528..3ee20ca 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -29,7 +29,7 @@ where let project_root = temp_dir.path(); git_add_all_files(project_root); let mut cmd = Command::cargo_bin("codeowners")?; - let assert = cmd.arg("--project-root").arg(project_root).arg("--no-cache").args(command).assert(); + let assert = cmd.arg("--project-root").arg(project_root).args(command).assert(); let assert = if success { assert.success() } else { assert.failure() }; match stream { OutputStream::Stdout => { @@ -156,7 +156,6 @@ pub fn build_run_config(project_root: &Path, codeowners_rel_path: &str) -> RunCo project_root, codeowners_file_path, config_path, - no_cache: true, } } diff --git a/tests/crosscheck_owners_test.rs b/tests/crosscheck_owners_test.rs index 2baf5cd..aff4816 100644 --- a/tests/crosscheck_owners_test.rs +++ b/tests/crosscheck_owners_test.rs @@ -30,7 +30,6 @@ fn test_crosscheck_owners_reports_team_mismatch() -> Result<(), Box> Command::cargo_bin("codeowners")? .arg("--project-root") .arg(project_root) - .arg("--no-cache") .arg("crosscheck-owners") .assert() .failure() @@ -62,7 +61,6 @@ fn test_crosscheck_owners_reports_unowned_mismatch() -> Result<(), Box>()).unwrap(); @@ -128,7 +126,6 @@ javascript_package_paths: project_root: td.path().to_path_buf(), codeowners_file_path: td.path().join(".github/CODEOWNERS"), config_path: td.path().join("config/code_ownership.yml"), - no_cache: true, }; // Ensure CODEOWNERS file matches generator output to avoid out-of-date errors @@ -169,7 +166,6 @@ javascript_package_paths: project_root: td.path().to_path_buf(), codeowners_file_path: td.path().join(".github/CODEOWNERS"), config_path: td.path().join("config/code_ownership.yml"), - no_cache: true, }; let gv = runner::generate_and_validate(&rc, vec![], true); diff --git a/tests/untracked_files_test.rs b/tests/untracked_files_test.rs index ee03479..d3a42a0 100644 --- a/tests/untracked_files_test.rs +++ b/tests/untracked_files_test.rs @@ -19,7 +19,6 @@ fn test_skip_untracked_files() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg(project_root) - .arg("--no-cache") .arg("gv") .assert() .failure(); @@ -29,7 +28,6 @@ fn test_skip_untracked_files() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg(project_root) - .arg("--no-cache") .arg("gv") .assert() .success(); diff --git a/tests/valid_project_test.rs b/tests/valid_project_test.rs index ca2aa56..6f556aa 100644 --- a/tests/valid_project_test.rs +++ b/tests/valid_project_test.rs @@ -101,7 +101,6 @@ fn test_for_file_full_path() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg(project_root) - .arg("--no-cache") .arg("for-file") .arg(for_file_absolute_path.to_str().unwrap()) .assert() @@ -124,7 +123,6 @@ fn test_for_file_full_path_json() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg(project_root) - .arg("--no-cache") .arg("for-file") .arg(for_file_absolute_path.to_str().unwrap()) .arg("--json") @@ -148,7 +146,6 @@ fn test_fast_for_file() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg("tests/fixtures/valid_project") - .arg("--no-cache") .arg("for-file") .arg("ruby/app/models/payroll.rb") .assert() @@ -168,7 +165,6 @@ fn test_fast_for_file_with_ignored_file() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg("tests/fixtures/valid_project") - .arg("--no-cache") .arg("for-file") .arg("should_be_ignored/an_ignored_file.rb") .assert() @@ -190,7 +186,6 @@ fn test_fast_for_file_full_path() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg(project_root) - .arg("--no-cache") .arg("for-file") .arg(for_file_absolute_path.to_str().unwrap()) .assert() @@ -210,7 +205,6 @@ fn test_for_file_with_components() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg("tests/fixtures/valid_project") - .arg("--no-cache") .arg("for-file") .arg("gems/pets/dog.rb") .assert() @@ -230,7 +224,6 @@ fn test_for_file_same_team_multiple_ownerships() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg("tests/fixtures/valid_project") - .arg("--no-cache") .arg("for-file") .arg("javascript/packages/PayrollFlow/index.tsx") .assert() @@ -251,7 +244,6 @@ fn test_fast_for_file_same_team_multiple_ownerships() -> Result<(), Box Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg("tests/fixtures/valid_project") - .arg("--no-cache") .arg("for-file") .arg("javascript/packages/PayrollFlow/index.tsx") .assert() @@ -335,7 +326,6 @@ fn test_for_missing_team() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg("tests/fixtures/valid_project") - .arg("--no-cache") .arg("for-team") .arg("Nope") .assert() diff --git a/tests/validate_files_test.rs b/tests/validate_files_test.rs index e1a2c7e..9518371 100644 --- a/tests/validate_files_test.rs +++ b/tests/validate_files_test.rs @@ -67,7 +67,6 @@ fn test_generate_and_validate_with_owned_files() -> Result<(), Box> { .arg(project_root) .arg("--codeowners-file-path") .arg(&codeowners_path) - .arg("--no-cache") .arg("generate-and-validate") .arg("ruby/app/models/payroll.rb") .arg("ruby/app/models/bank_account.rb") @@ -91,7 +90,6 @@ fn test_generate_and_validate_with_unowned_file() -> Result<(), Box> .arg(project_root) .arg("--codeowners-file-path") .arg(&codeowners_path) - .arg("--no-cache") .arg("generate-and-validate") .arg("ruby/app/unowned.rb") .assert() @@ -114,7 +112,6 @@ fn test_validate_with_absolute_path() -> Result<(), Box> { Command::cargo_bin("codeowners")? .arg("--project-root") .arg(project_root) - .arg("--no-cache") .arg("validate") .arg(file_absolute_path.to_str().unwrap()) .assert()