@@ -30,9 +30,14 @@ check_dnct() {
30
30
return $SUCCESS
31
31
fi
32
32
33
- # check if the commit message has the DNCT tag
33
+ # run the git diff
34
34
local _spoted
35
- _spoted=" $( git diff --cached --name-only --diff-filter=AM -p -G " $DNCT_REGEX " ) "
35
+ if ! _spoted=" $( git diff --cached --name-only --diff-filter=AM -p -G " $DNCT_REGEX " ) " ; then
36
+ error " Unexpected error from git diff check your repository"
37
+ return $FAILURE
38
+ fi
39
+
40
+ # check if the commit message has the DNCT tag
36
41
if [[ -n $_spoted ]]; then
37
42
error " DNCT tag are spoted in commit, see files below to fix it:"
38
43
@@ -49,7 +54,7 @@ check_dnct() {
49
54
# # check_dsstore is a function to check if a DSStore file is spoted in commit
50
55
check_dsstore () {
51
56
# check if this flag is enabled
52
- if [[ $FILE_IGNORE_DSSTORE -eq $TRUE ]]; then
57
+ if [[ $FILE_UNCACHE_DSSTORE -eq $FALSE ]]; then
53
58
return $SUCCESS
54
59
fi
55
60
@@ -61,9 +66,8 @@ check_dsstore() {
61
66
local _file=" $1 "
62
67
63
68
# check if the file is a DSStore file
64
- if [[ $_file == * " /.ds_store" ]]; then
65
- git_uncache " $_file "
66
- return $FAILURE
69
+ if grep -i " \.ds_store$" <<< " $_file" > /dev/null 2>> " $LOG_FILE " ; then
70
+ git_uncache " $_file " || return $FAILURE
67
71
fi
68
72
69
73
return $SUCCESS
@@ -72,7 +76,7 @@ check_dsstore() {
72
76
# # check_binary is a function to check if a binary file is spoted in commit
73
77
check_binary () {
74
78
# check if this flag is enabled
75
- if [[ $FILE_IGNORE_BINARY -eq $TRUE ]]; then
79
+ if [[ $FILE_UNCACHE_BINARY -eq $FALSE ]]; then
76
80
return $SUCCESS
77
81
fi
78
82
@@ -89,12 +93,12 @@ check_binary() {
89
93
return $SUCCESS
90
94
fi
91
95
92
- case $FILE_IGNORE_BINARY in
96
+ case $FILE_UNCACHE_BINARY in
93
97
" $TRUE " )
94
98
git_uncache " $_file "
95
99
;;
96
100
" $SUPERPOSITION " )
97
- interactive_remove " Executable binary" " $_file "
101
+ interactive_uncache " Executable binary" " $_file "
98
102
;;
99
103
* )
100
104
return $SUCCESS
@@ -106,7 +110,7 @@ check_binary() {
106
110
107
111
# # check_size is a function to check if file size is greater than the limit
108
112
check_size () {
109
- # check if this flag is enabled
113
+ # check if this flag is disabled
110
114
if [[ $FILE_MAX_SIZE -lt 1 ]]; then
111
115
return $SUCCESS
112
116
fi
@@ -123,22 +127,21 @@ check_size() {
123
127
if ! _size=$( stat -c%s " $_file " 2> /dev/null) ; then
124
128
return $FAILURE
125
129
fi
126
- # convert it to KB
127
130
_size=$(( _size / 1024 ))
128
131
129
- # check if the file size is greater than the limit
130
- # if limit is 0 or less, then no check is done
132
+ # check the file size
131
133
if [[ $_size -lt $FILE_MAX_SIZE ]]; then
132
134
return $SUCCESS
133
135
fi
134
136
135
- case $FILE_SIZE_AUTOFIX in
137
+ case $FILE_UNCACHE_OVERSIZE in
136
138
" $TRUE " )
137
- git_uncache " $_file "
139
+ git_uncache " $_file " && return $SUCCESS
138
140
;;
139
141
" $SUPERPOSITION " )
140
- interactive_remove \
141
- " ${_size} KB exceeds limit of ${FILE_MAX_SIZE} KB for a" " $_file "
142
+ interactive_uncache \
143
+ " ${_size} KB exceeds limit of ${FILE_MAX_SIZE} KB for a" " $_file " \
144
+ && return $SUCCESS
142
145
;;
143
146
* )
144
147
return $SUCCESS
@@ -180,6 +183,6 @@ if [[ ${BASH_SOURCE[0]} -ef "$0" ]]; then
180
183
continue
181
184
fi
182
185
done
183
- fi
184
186
185
- exit $SUCCESS
187
+ exit $SUCCESS
188
+ fi
0 commit comments