Skip to content

Commit 4ffa670

Browse files
authored
Merge pull request #167 from intel/dont-use-git2
Do not use git2
2 parents db69bac + 7dea514 commit 4ffa670

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ crossbeam = "0.8"
3232
crossbeam-deque = "0.8.1"
3333
crossbeam-utils = "0.8.7"
3434
env_logger = "0.11"
35-
git2 = "0.20.2"
3635
itertools = "0.14"
3736
jsonrpc = "0.18"
3837
lsp-types = { version = "0.97" }

src/file_tests.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@
1919

2020
#[cfg(test)]
2121
mod test {
22-
fn get_indexed_files_with_extension(extension: &'static str) -> Vec<String> {
23-
let repo = git2::Repository::open(".").expect("Could not open git repository");
24-
let index = repo.index().expect("Could not get git index");
25-
index.iter().filter_map(move |entry| {
26-
let path = std::str::from_utf8(&entry.path).expect("Invalid UTF-8 in file path");
27-
if path.ends_with(extension) {
28-
Some(path.to_string())
29-
} else {
30-
None
31-
}
32-
}).collect()
22+
fn get_files_with_extension(extension: &'static str) -> Vec<String> {
23+
let files = walkdir::WalkDir::new(".");
24+
files.into_iter()
25+
.filter_map(|e|e.ok())
26+
.filter(|e|!e.path().starts_with("./target"))
27+
.filter_map(move |entry| {
28+
let path = entry.path().to_str()
29+
.expect("Invalid Unicode in file path");
30+
if path.ends_with(extension) {
31+
Some(path.to_string())
32+
} else {
33+
None
34+
}
35+
}).collect()
3336
}
3437

3538
fn compare_linewise(canon: &str, content: &str) -> bool {
@@ -44,7 +47,7 @@ mod test {
4447
#[test]
4548
fn check_copyright_headers_rs() {
4649
let mut missmatching_files = vec![];
47-
for path in get_indexed_files_with_extension(".rs") {
50+
for path in get_files_with_extension(".rs") {
4851
let content = std::fs::read_to_string(&path)
4952
.unwrap_or_else(|e|panic!("Could not read file {}, {}", path, e));
5053
if !compare_linewise(
@@ -63,7 +66,7 @@ mod test {
6366
#[test]
6467
fn check_copyright_headers_md() {
6568
let mut missmatching_files = vec![];
66-
for path in get_indexed_files_with_extension(".md") {
69+
for path in get_files_with_extension(".md") {
6770
let content = std::fs::read_to_string(&path)
6871
.unwrap_or_else(|e| panic!("Could not read file {}, {}", path, e));
6972
if !compare_linewise(
@@ -80,4 +83,4 @@ mod test {
8083
missmatching_files.join("\n"));
8184
}
8285
}
83-
}
86+
}

0 commit comments

Comments
 (0)