Skip to content

Commit daacced

Browse files
authored
Use noop cache when disabled (#47)
* use noop cache when disabled * updating run_benchmark.sh comment
1 parent c31eeff commit daacced

File tree

5 files changed

+8
-25
lines changed

5 files changed

+8
-25
lines changed

dev/run_benchmarks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if [ -f "tmp/codeowners_benchmarks.md" ]; then
55
rm tmp/codeowners_benchmarks.md
66
fi
77

8-
echo "To run these benchmarks on your application, you can place this repo next to your rails application and run bash ../rubyatscale/codeowners-rs/dev/run_benchmarks.sh from the root of your application" >> tmp/codeowners_benchmarks.md
8+
echo "To run these benchmarks on your application, you can place this repo next to your rails application and run /usr/bin/env bash ../rubyatscale/codeowners-rs/dev/run_benchmarks.sh from the root of your application" >> tmp/codeowners_benchmarks.md
99

1010
hyperfine --warmup=2 --runs=3 --export-markdown tmp/codeowners_benchmarks.md \
1111
'../rubyatscale/codeowners-rs/target/release/codeowners gv' \

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn cli() -> Result<(), Error> {
109109
.into()
110110
};
111111

112-
let mut project_builder = ProjectBuilder::new(&config, project_root.clone(), codeowners_file_path.clone(), !args.no_cache, &cache);
112+
let mut project_builder = ProjectBuilder::new(&config, project_root.clone(), codeowners_file_path.clone(), &cache);
113113
let project = project_builder.build().change_context(Error::Io)?;
114114
let ownership = Ownership::build(project);
115115

src/common_test.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,14 @@ pub mod tests {
116116

117117
let codeowners_file_path = &test_config.temp_dir_path.join(".github/CODEOWNERS");
118118
let cache: Cache = NoopCache::default().into();
119-
let mut builder = ProjectBuilder::new(
120-
&config,
121-
test_config.temp_dir_path.clone(),
122-
codeowners_file_path.clone(),
123-
false,
124-
&cache,
125-
);
119+
let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone(), &cache);
126120
let project = builder.build()?;
127121
let ownership = Ownership::build(project);
128122
if test_config.generate_codeowners {
129123
std::fs::write(codeowners_file_path, ownership.generate_file())?;
130124
}
131125
// rebuild project to ensure new codeowners file is read
132-
let mut builder = ProjectBuilder::new(
133-
&config,
134-
test_config.temp_dir_path.clone(),
135-
codeowners_file_path.clone(),
136-
false,
137-
&cache,
138-
);
126+
let mut builder = ProjectBuilder::new(&config, test_config.temp_dir_path.clone(), codeowners_file_path.clone(), &cache);
139127
let project = builder.build()?;
140128
Ok(Ownership::build(project))
141129
}

src/project_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ pub struct ProjectBuilder<'a> {
3838
const INITIAL_VECTOR_CAPACITY: usize = 1000;
3939

4040
impl<'a> ProjectBuilder<'a> {
41-
pub fn new(config: &'a Config, base_path: PathBuf, codeowners_file_path: PathBuf, use_cache: bool, cache: &'a Cache) -> Self {
42-
let project_file_builder = ProjectFileBuilder::new(use_cache, cache);
41+
pub fn new(config: &'a Config, base_path: PathBuf, codeowners_file_path: PathBuf, cache: &'a Cache) -> Self {
42+
let project_file_builder = ProjectFileBuilder::new(cache);
4343
Self {
4444
project_file_builder,
4545
config,

src/project_file_builder.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::{
99
};
1010

1111
pub struct ProjectFileBuilder<'a> {
12-
use_cache: bool,
1312
global_cache: &'a Cache,
1413
}
1514

@@ -18,15 +17,11 @@ lazy_static! {
1817
}
1918

2019
impl<'a> ProjectFileBuilder<'a> {
21-
pub fn new(use_cache: bool, global_cache: &'a Cache) -> Self {
22-
Self { use_cache, global_cache }
20+
pub fn new(global_cache: &'a Cache) -> Self {
21+
Self { global_cache }
2322
}
2423

2524
pub(crate) fn build(&mut self, path: PathBuf) -> ProjectFile {
26-
if !self.use_cache {
27-
return build_project_file_without_cache(&path);
28-
}
29-
3025
if let Ok(Some(cached_project_file)) = self.get_project_file_from_cache(&path) {
3126
return cached_project_file;
3227
}

0 commit comments

Comments
 (0)