Skip to content

Commit a998eff

Browse files
committed
jwalk spike
1 parent 97e385a commit a998eff

File tree

3 files changed

+56
-17
lines changed

3 files changed

+56
-17
lines changed

Cargo.lock

Lines changed: 44 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ error-stack = "0.5.0"
1313
glob-match = "0.2.1"
1414
ignore = "0.4.23"
1515
itertools = "0.13.0"
16+
jwalk = "0.8.1"
1617
path-clean = "1.0.1"
1718
rayon = "1.10.0"
1819
regex = "1.11.1"

src/project.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::{
99

1010
use error_stack::{Context, Result, ResultExt};
1111

12-
use ignore::WalkBuilder;
12+
use jwalk::WalkDir;
1313
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
1414
use regex::Regex;
1515
use tracing::{info, instrument};
@@ -165,17 +165,15 @@ impl Project {
165165
let mut vendored_gems: Vec<VendoredGem> = Vec::new();
166166
let mut directory_codeowner_files: Vec<DirectoryCodeownersFile> = Vec::new();
167167

168-
let mut builder = WalkBuilder::new(base_path);
169-
builder.hidden(false);
170-
let walkdir = builder.build();
171-
172-
for entry in walkdir {
173-
let entry = entry.change_context(Error::Io)?;
174-
168+
for entry in WalkDir::new(base_path).follow_links(true).skip_hidden(false).into_iter() {
169+
let entry = match entry.change_context(Error::Io) {
170+
Ok(entry) => entry,
171+
Err(_) => continue,
172+
};
175173
let absolute_path = entry.path();
176174
let relative_path = absolute_path.strip_prefix(base_path).change_context(Error::Io)?.to_owned();
177175

178-
if entry.file_type().unwrap().is_dir() {
176+
if entry.file_type().is_dir() {
179177
if relative_path.parent() == Some(Path::new(&config.vendored_gems_path)) {
180178
let file_name = relative_path.file_name().expect("expected a file_name");
181179
vendored_gems.push(VendoredGem {
@@ -190,7 +188,7 @@ impl Project {
190188
let file_name = relative_path.file_name().expect("expected a file_name");
191189

192190
if file_name.eq_ignore_ascii_case("package.yml") && matches_globs(relative_path.parent().unwrap(), &config.ruby_package_paths) {
193-
if let Some(owner) = ruby_package_owner(absolute_path)? {
191+
if let Some(owner) = ruby_package_owner(&absolute_path)? {
194192
packages.push(Package {
195193
path: relative_path.clone(),
196194
owner,
@@ -202,7 +200,7 @@ impl Project {
202200
if file_name.eq_ignore_ascii_case("package.json")
203201
&& matches_globs(relative_path.parent().unwrap(), &config.javascript_package_paths)
204202
{
205-
if let Some(owner) = javascript_package_owner(absolute_path)? {
203+
if let Some(owner) = javascript_package_owner(&absolute_path)? {
206204
packages.push(Package {
207205
path: relative_path.clone(),
208206
owner,
@@ -212,7 +210,7 @@ impl Project {
212210
}
213211

214212
if file_name.eq_ignore_ascii_case(".codeowner") {
215-
let owner = std::fs::read_to_string(absolute_path).change_context(Error::Io)?;
213+
let owner = std::fs::read_to_string(&absolute_path).change_context(Error::Io)?;
216214
let owner = owner.trim().to_owned();
217215

218216
let relative_path = relative_path.to_owned();
@@ -223,7 +221,7 @@ impl Project {
223221
}
224222

225223
if matches_globs(&relative_path, &config.team_file_glob) {
226-
let file = File::open(absolute_path).change_context(Error::Io)?;
224+
let file = File::open(&absolute_path).change_context(Error::Io)?;
227225
let deserializer: deserializers::Team = serde_yaml::from_reader(file).change_context(Error::SerdeYaml)?;
228226

229227
teams.push(Team {

0 commit comments

Comments
 (0)