File tree Expand file tree Collapse file tree 2 files changed +18
-32
lines changed Expand file tree Collapse file tree 2 files changed +18
-32
lines changed Original file line number Diff line number Diff line change @@ -24,30 +24,23 @@ fn main() -> std::io::Result<()> {
24
24
. arg ( "--working-dir=." )
25
25
. arg ( db) ;
26
26
27
- let pwd = env:: current_dir ( ) ?;
28
27
for line in env:: var ( "LGTM_INDEX_FILTERS" )
29
28
. unwrap_or_default ( )
30
29
. split ( '\n' )
31
30
{
32
31
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) ) ;
40
33
} 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) ;
49
35
}
50
36
}
51
37
let exit = & cmd. spawn ( ) ?. wait ( ) ?;
52
38
std:: process:: exit ( exit. code ( ) . unwrap_or ( 1 ) )
53
39
}
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
+ }
Original file line number Diff line number Diff line change @@ -24,30 +24,23 @@ fn main() -> std::io::Result<()> {
24
24
. arg ( "--working-dir=." )
25
25
. arg ( db) ;
26
26
27
- let pwd = env:: current_dir ( ) ?;
28
27
for line in env:: var ( "LGTM_INDEX_FILTERS" )
29
28
. unwrap_or_default ( )
30
29
. split ( '\n' )
31
30
{
32
31
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) ) ;
40
33
} 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) ;
49
35
}
50
36
}
51
37
let exit = & cmd. spawn ( ) ?. wait ( ) ?;
52
38
std:: process:: exit ( exit. code ( ) . unwrap_or ( 1 ) )
53
39
}
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
+ }
You can’t perform that action at this time.
0 commit comments