Skip to content

Commit

Permalink
Merge pull request #823 from luxaritas/fix/vcs-fullpath
Browse files Browse the repository at this point in the history
Fix --no-match when combined with --fullpath and --vcs, #823
  • Loading branch information
AlDanial committed Mar 21, 2024
2 parents 02a5c9c + cb08685 commit 8303fb7
Show file tree
Hide file tree
Showing 12 changed files with 232 additions and 3 deletions.
55 changes: 55 additions & 0 deletions Unix/t/01_opts.t
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,61 @@ my @Tests = (
'ref' => '../tests/outputs/issues/816/results.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T1)',
'cd' => '../tests/inputs',
'args' => '--fullpath --not-match-f "^c.csv" issues/822',
'ref' => '../tests/outputs/issues/822/T1.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T2)',
'cd' => '../tests/inputs',
'args' => '--vcs git --fullpath --not-match-f "^c.csv" issues/822',
'ref' => '../tests/outputs/issues/822/T2.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T3)',
'cd' => '../tests/inputs',
'args' => '--fullpath --not-match-f "b/c.csv" issues/822',
'ref' => '../tests/outputs/issues/822/T3.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T4)',
'cd' => '../tests/inputs',
'args' => '--vcs git --fullpath --not-match-f "b/c.csv" issues/822',
'ref' => '../tests/outputs/issues/822/T4.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T5)',
'cd' => '../tests/inputs',
'args' => '--fullpath --not-match-d "^b" issues/822',
'ref' => '../tests/outputs/issues/822/T5.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T6)',
'cd' => '../tests/inputs',
'args' => '--vcs git --fullpath --not-match-d "^b" issues/822',
'ref' => '../tests/outputs/issues/822/T6.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T7)',
'cd' => '../tests/inputs',
'args' => '--fullpath --not-match-d "a/b" issues/822',
'ref' => '../tests/outputs/issues/822/T7.yaml',
},

{
'name' => '--fullpath issues/822 (github issue #822 T8)',
'cd' => '../tests/inputs',
'args' => '--vcs git --fullpath --not-match-d "a/b" issues/822',
'ref' => '../tests/outputs/issues/822/T8.yaml',
},
);

# Special cases:
Expand Down
9 changes: 6 additions & 3 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -5807,15 +5807,18 @@ sub invoke_generator { # {{{1
if ($opt_fullpath and any_match($F, 0, \$rule, @opt_not_match_d)) {
$Ignored{$F} = "--not-match-d=$rule";
next;
} elsif (any_match(basename($F), 0, \$rule, @opt_not_match_d)) {
} elsif (!$opt_fullpath and any_match(basename($F), 0, \$rule, @opt_not_match_d)) {
$Ignored{$F} = "--not-match-d (basename) =$rule";
next;
}
}
if (@opt_not_match_f) {
my $rule;
if (any_match(basename($F), 0, \$rule, @opt_not_match_f)) {
$Ignored{$F} = "--not-match-d =$rule";
if ($opt_fullpath and any_match($F, 0, \$rule, @opt_not_match_f)) {
$Ignored{$F} = "--not-match-f=$rule";
next;
} elsif (!$opt_fullpath and any_match(basename($F), 0, \$rule, @opt_not_match_f)) {
$Ignored{$F} = "--not-match-f (basename) =$rule";
next;
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/inputs/issues/822/a.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
111,222
2 changes: 2 additions & 0 deletions tests/inputs/issues/822/a/b/c.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
aaa,bbb
ccc,ddd
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.00448489189147949
n_files : 2
n_lines : 3
files_per_second : 445.9416298974
lines_per_second : 668.912444846101
report_file : ../outputs/issues/822/T1.yaml
'CSV' :
nFiles: 2
blank: 0
comment: 0
code: 3
SUM:
blank: 0
comment: 0
code: 3
nFiles: 2
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.0277459621429443
n_files : 2
n_lines : 3
files_per_second : 72.0825606874329
lines_per_second : 108.123841031149
report_file : ../outputs/issues/822/T2.yaml
'CSV' :
nFiles: 2
blank: 0
comment: 0
code: 3
SUM:
blank: 0
comment: 0
code: 3
nFiles: 2
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.00403499603271484
n_files : 1
n_lines : 1
files_per_second : 247.831718269913
lines_per_second : 247.831718269913
report_file : ../outputs/issues/822/T3.yaml
'CSV' :
nFiles: 1
blank: 0
comment: 0
code: 1
SUM:
blank: 0
comment: 0
code: 1
nFiles: 1
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.0277609825134277
n_files : 1
n_lines : 1
files_per_second : 36.0217798313265
lines_per_second : 36.0217798313265
report_file : ../outputs/issues/822/T4.yaml
'CSV' :
nFiles: 1
blank: 0
comment: 0
code: 1
SUM:
blank: 0
comment: 0
code: 1
nFiles: 1
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.00425601005554199
n_files : 2
n_lines : 3
files_per_second : 469.923701753403
lines_per_second : 704.885552630105
report_file : ../outputs/issues/822/T5.yaml
'CSV' :
nFiles: 2
blank: 0
comment: 0
code: 3
SUM:
blank: 0
comment: 0
code: 3
nFiles: 2
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.0273749828338623
n_files : 2
n_lines : 3
files_per_second : 73.0594065442131
lines_per_second : 109.58910981632
report_file : ../outputs/issues/822/T6.yaml
'CSV' :
nFiles: 2
blank: 0
comment: 0
code: 3
SUM:
blank: 0
comment: 0
code: 3
nFiles: 2
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.00388598442077637
n_files : 1
n_lines : 1
files_per_second : 257.335051230137
lines_per_second : 257.335051230137
report_file : ../outputs/issues/822/T7.yaml
'CSV' :
nFiles: 1
blank: 0
comment: 0
code: 1
SUM:
blank: 0
comment: 0
code: 1
nFiles: 1
21 changes: 21 additions & 0 deletions tests/outputs/issues/822/T8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.01
elapsed_seconds : 0.0281188488006592
n_files : 1
n_lines : 1
files_per_second : 35.5633335877021
lines_per_second : 35.5633335877021
report_file : ../outputs/issues/822/T8.yaml
'CSV' :
nFiles: 1
blank: 0
comment: 0
code: 1
SUM:
blank: 0
comment: 0
code: 1
nFiles: 1

0 comments on commit 8303fb7

Please sign in to comment.