Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
179 changes: 0 additions & 179 deletions src/cache/file.rs

This file was deleted.

29 changes: 0 additions & 29 deletions src/cache/mod.rs

This file was deleted.

26 changes: 0 additions & 26 deletions src/cache/noop.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -113,7 +109,6 @@ pub fn cli() -> Result<RunResult, RunnerError> {
config_path,
codeowners_file_path,
project_root,
no_cache: args.no_cache,
};

let runner_result = match args.command {
Expand Down
12 changes: 3 additions & 9 deletions src/common_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),+) => {{
Expand Down Expand Up @@ -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))
}
Expand Down
18 changes: 6 additions & 12 deletions src/crosscheck.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use std::path::Path;

use crate::{
cache::Cache,
config::Config,
ownership::file_owner_resolver::find_file_owners,
project::Project,
project_builder::ProjectBuilder,
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()
Expand All @@ -26,9 +25,9 @@ pub fn crosscheck_owners(run_config: &RunConfig, cache: &Cache) -> RunResult {
}
}

fn do_crosscheck_owners(run_config: &RunConfig, cache: &Cache) -> Result<Vec<String>, String> {
fn do_crosscheck_owners(run_config: &RunConfig) -> Result<Vec<String>, 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<String> = Vec::new();
for file in &project.files {
Expand All @@ -46,13 +45,8 @@ fn load_config(run_config: &RunConfig) -> Result<Config, String> {
config_from_path(&run_config.config_path).map_err(|e| e.to_string())
}

fn build_project(config: &Config, run_config: &RunConfig, cache: &Cache) -> Result<Project, String> {
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<Project, String> {
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())
}

Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
pub mod cache;
pub(crate) mod common_test;
pub mod config;
pub mod crosscheck;
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;
10 changes: 3 additions & 7 deletions src/ownership/file_owner_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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<String> {
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(
Expand Down
Loading