File tree Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ find . -type f -exec bash -c " [ ! -s \" {}\" ] && rm \" {}\" " \;
Original file line number Diff line number Diff line change @@ -55,15 +55,21 @@ check_file () {
55
55
patch_file=" ${label} -${cxx_compiler} -${cxx_std} -${cxx_stdlib} .patch"
56
56
57
57
if [[ $untracked -eq 1 ]]; then
58
- # Add the file to the index to be able to diff it...
59
- git add " $file "
60
- # ... report the diff ...
61
- report_diff " $file " \
62
- " The $description is not tracked by git" \
63
- " $patch_file " \
64
- " HEAD"
65
- # ... and remove the file from the index
66
- git rm --cached -- " $file " > /dev/null 2>&1
58
+ # Untraced files are expected to be empty - report if they are not
59
+ if [[ -s " " $file " " ]]; then
60
+ # Add the file to the index to be able to diff it...
61
+ git add " $file "
62
+ # ... report the diff ...
63
+ report_diff " $file " \
64
+ " The $description is not tracked by git, it is expected to be empty" \
65
+ " $patch_file " \
66
+ " HEAD"
67
+ # ... and remove the file from the index
68
+ git rm --cached -- " $file " > /dev/null 2>&1
69
+ else
70
+ # The file is empty as expected - it can be removed
71
+ rm " $file "
72
+ fi
67
73
else
68
74
# Compare the content with the reference value checked in git
69
75
# Lines includng Windows paths are excluded from diff
@@ -73,6 +79,13 @@ check_file () {
73
79
" Non-matching $description " \
74
80
" $patch_file " \
75
81
--ignore-cr-at-eol
82
+
83
+ # If the file is tracked an empty report an error
84
+ if [[ $failure != 1 && ! -s " $file " ]]; then
85
+ echo " Empty tracked file:"
86
+ echo " $file "
87
+ failure=1
88
+ fi
76
89
fi
77
90
}
78
91
You can’t perform that action at this time.
0 commit comments