From cea8f2703a3e4329948e91a95813119613943fb9 Mon Sep 17 00:00:00 2001 From: Khanh Duong Date: Sat, 13 Sep 2025 08:22:42 +0900 Subject: [PATCH] fix: working with absolute filepath (#593) --- CHANGELOG.md | 2 ++ Cargo.lock | 7 +++++++ selene/Cargo.toml | 1 + selene/src/main.rs | 9 +++++---- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7caf7b34..784849af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased](https://github.com/Kampfkarren/selene/compare/0.29.0...HEAD) +### Fixed +- Fixed exclude not working with absolute path in some cases ([#593](https://github.com/Kampfkarren/selene/issues/593)) ## [0.29.0](https://github.com/Kampfkarren/selene/releases/tag/0.29.0) - 2025-07-23 - Added `Instance.fromExisting` to the Roblox standard library diff --git a/Cargo.lock b/Cargo.lock index 3bf340bf..100a57d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -709,6 +709,12 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +[[package]] +name = "pathdiff" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" + [[package]] name = "percent-encoding" version = "2.2.0" @@ -933,6 +939,7 @@ dependencies = [ "globset", "lazy_static", "num_cpus", + "pathdiff", "pretty_assertions", "profiling", "selene-lib", diff --git a/selene/Cargo.toml b/selene/Cargo.toml index 1a92729d..b60ddfa4 100644 --- a/selene/Cargo.toml +++ b/selene/Cargo.toml @@ -35,6 +35,7 @@ tracy-client = { version = "0.14.1", optional = true } threadpool = "1.8" toml.workspace = true ureq = { version = "2.6.2", features = ["json"], optional = true } +pathdiff = "0.2.3" [dev-dependencies] pretty_assertions = "1.3" diff --git a/selene/src/main.rs b/selene/src/main.rs index 3e67e471..224b0d7a 100644 --- a/selene/src/main.rs +++ b/selene/src/main.rs @@ -643,17 +643,18 @@ fn start(mut options: opts::Options) { continue; } - match fs::metadata(filename) { + let filename = + pathdiff::diff_paths(filename, ¤t_dir).unwrap_or_else(|| PathBuf::from(filename)); + + match fs::metadata(&filename) { Ok(metadata) => { if metadata.is_file() { let checker = Arc::clone(&checker); - let filename = filename.to_owned(); - if !options.no_exclude && exclude_set.is_match(&filename) { continue; } - pool.execute(move || read_file(&checker, lua_version, Path::new(&filename))); + pool.execute(move || read_file(&checker, lua_version, &filename)); } else if metadata.is_dir() { for pattern in &options.pattern { let glob = match glob::glob(&format!(