Skip to content

Commit eb0340d

Browse files
committed
get excludes to work properly
1 parent 8781683 commit eb0340d

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

ql/autobuilder/src/main.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,23 @@ fn main() -> std::io::Result<()> {
2424
.arg("--working-dir=.")
2525
.arg(db);
2626

27-
let pwd = env::current_dir()?;
2827
for line in env::var("LGTM_INDEX_FILTERS")
2928
.unwrap_or_default()
3029
.split('\n')
3130
{
3231
if let Some(stripped) = line.strip_prefix("include:") {
33-
let path = pwd
34-
.join(stripped)
35-
.join("**")
36-
.into_os_string()
37-
.into_string()
38-
.unwrap();
39-
cmd.arg("--also-match").arg(path);
32+
cmd.arg("--also-match").arg(absolutelyfy(stripped));
4033
} else if let Some(stripped) = line.strip_prefix("exclude:") {
41-
let path = pwd
42-
.join(stripped)
43-
.join("**")
44-
.into_os_string()
45-
.into_string()
46-
.unwrap();
47-
// the same as above, but starting with "!"
48-
cmd.arg("--also-match").arg("!".to_owned() + &path);
34+
cmd.arg("--exclude").arg(stripped);
4935
}
5036
}
5137
let exit = &cmd.spawn()?.wait()?;
5238
std::process::exit(exit.code().unwrap_or(1))
5339
}
40+
41+
// converts the relative path `stripped` to an absolute path by prepending the working directory
42+
fn absolutelyfy(stripped: &str) -> String {
43+
let pwd = env::current_dir().unwrap();
44+
45+
pwd.join(stripped).into_os_string().into_string().unwrap()
46+
}

ruby/autobuilder/src/main.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,23 @@ fn main() -> std::io::Result<()> {
2424
.arg("--working-dir=.")
2525
.arg(db);
2626

27-
let pwd = env::current_dir()?;
2827
for line in env::var("LGTM_INDEX_FILTERS")
2928
.unwrap_or_default()
3029
.split('\n')
3130
{
3231
if let Some(stripped) = line.strip_prefix("include:") {
33-
let path = pwd
34-
.join(stripped)
35-
.join("**")
36-
.into_os_string()
37-
.into_string()
38-
.unwrap();
39-
cmd.arg("--also-match").arg(path);
32+
cmd.arg("--also-match").arg(absolutelyfy(stripped));
4033
} else if let Some(stripped) = line.strip_prefix("exclude:") {
41-
let path = pwd
42-
.join(stripped)
43-
.join("**")
44-
.into_os_string()
45-
.into_string()
46-
.unwrap();
47-
// the same as above, but starting with "!"
48-
cmd.arg("--also-match").arg("!".to_owned() + &path);
34+
cmd.arg("--exclude").arg(stripped);
4935
}
5036
}
5137
let exit = &cmd.spawn()?.wait()?;
5238
std::process::exit(exit.code().unwrap_or(1))
5339
}
40+
41+
// converts the relative path `stripped` to an absolute path by prepending the working directory
42+
fn absolutelyfy(stripped: &str) -> String {
43+
let pwd = env::current_dir().unwrap();
44+
45+
pwd.join(stripped).into_os_string().into_string().unwrap()
46+
}

0 commit comments

Comments
 (0)