From 7dea51481ad5198e06d855c8128670d58f5bbce7 Mon Sep 17 00:00:00 2001 From: Jonatan Waern Date: Mon, 10 Nov 2025 14:42:19 +0100 Subject: [PATCH] Do not use git2 git2 requires openssl-sys, which does not compile as portably as we'd like Signed-off-by: Jonatan Waern --- Cargo.toml | 1 - src/file_tests.rs | 31 +++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 65299bc..69a360f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,6 @@ crossbeam = "0.8" crossbeam-deque = "0.8.1" crossbeam-utils = "0.8.7" env_logger = "0.11" -git2 = "0.20.2" itertools = "0.14" jsonrpc = "0.18" lsp-types = { version = "0.97" } diff --git a/src/file_tests.rs b/src/file_tests.rs index c74de0b..b5c55e2 100644 --- a/src/file_tests.rs +++ b/src/file_tests.rs @@ -19,17 +19,20 @@ #[cfg(test)] mod test { - fn get_indexed_files_with_extension(extension: &'static str) -> Vec { - let repo = git2::Repository::open(".").expect("Could not open git repository"); - let index = repo.index().expect("Could not get git index"); - index.iter().filter_map(move |entry| { - let path = std::str::from_utf8(&entry.path).expect("Invalid UTF-8 in file path"); - if path.ends_with(extension) { - Some(path.to_string()) - } else { - None - } - }).collect() + fn get_files_with_extension(extension: &'static str) -> Vec { + let files = walkdir::WalkDir::new("."); + files.into_iter() + .filter_map(|e|e.ok()) + .filter(|e|!e.path().starts_with("./target")) + .filter_map(move |entry| { + let path = entry.path().to_str() + .expect("Invalid Unicode in file path"); + if path.ends_with(extension) { + Some(path.to_string()) + } else { + None + } + }).collect() } fn compare_linewise(canon: &str, content: &str) -> bool { @@ -44,7 +47,7 @@ mod test { #[test] fn check_copyright_headers_rs() { let mut missmatching_files = vec![]; - for path in get_indexed_files_with_extension(".rs") { + for path in get_files_with_extension(".rs") { let content = std::fs::read_to_string(&path) .unwrap_or_else(|e|panic!("Could not read file {}, {}", path, e)); if !compare_linewise( @@ -63,7 +66,7 @@ mod test { #[test] fn check_copyright_headers_md() { let mut missmatching_files = vec![]; - for path in get_indexed_files_with_extension(".md") { + for path in get_files_with_extension(".md") { let content = std::fs::read_to_string(&path) .unwrap_or_else(|e| panic!("Could not read file {}, {}", path, e)); if !compare_linewise( @@ -80,4 +83,4 @@ mod test { missmatching_files.join("\n")); } } -} \ No newline at end of file +}