1
1
#! /usr/bin/env bash
2
- CC_WRAPPER_VERSION=" 0.0.24 "
2
+ CC_WRAPPER_VERSION=" 0.0.26 "
3
3
set +u
4
4
say () {
5
5
echo -e " $1 "
@@ -15,16 +15,22 @@ exit_if_error() {
15
15
lower () {
16
16
echo $( echo $1 | sed ' s/CC//' | sed ' s/_/-/g' | tr ' [:upper:]' ' [:lower:]' )
17
17
}
18
- write_existing_args () {
19
- if [ -n " $( eval echo \$ $1 ) " ];
18
+ k_arg () {
19
+ if [ -n " $( eval echo \$ " CC_ $1 " ) " ];
20
20
then
21
- echo " -$( lower " $1 " ) $( eval echo \$ $1 ) "
21
+ echo " --$( lower " $1 " ) "
22
+ fi
23
+ }
24
+ v_arg () {
25
+ if [ -n " $( eval echo \$ " CC_$1 " ) " ];
26
+ then
27
+ echo " $( eval echo \$ " CC_$1 " ) "
22
28
fi
23
29
}
24
30
write_truthy_args () {
25
31
if [ " $( eval echo \$ $1 ) " = " true" ] || [ " $( eval echo \$ $1 ) " = " 1" ];
26
32
then
27
- echo " -$( lower $1 ) "
33
+ echo " -$( lower $1 ) "
28
34
fi
29
35
}
30
36
b=" \033[0;36m" # variables/constants
@@ -115,77 +121,80 @@ CC_PUBLIC_PGP_KEY=$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)
115
121
say
116
122
fi
117
123
cc_cli_args=()
118
- cc_cli_args+=( $( write_existing_args CC_AUTO_LOAD_PARAMS_FROM ) )
119
- cc_cli_args+=( $( write_existing_args CC_ENTERPRISE_URL ) )
120
- cc_cli_args+=( $( write_existing_args CC_YML_PATH ) )
124
+ cc_cli_args+=( $( k_arg AUTO_LOAD_PARAMS_FROM ) $( v_arg AUTO_LOAD_PARAMS_FROM ) )
125
+ cc_cli_args+=( $( k_arg ENTERPRISE_URL ) $( v_arg ENTERPRISE_URL ) )
126
+ cc_cli_args+=( $( k_arg YML_PATH ) $( v_arg YML_PATH ) )
121
127
cc_cli_args+=( $( write_truthy_args CC_VERBOSE) )
122
128
cc_cc_args=()
123
129
cc_cc_args+=( $( write_truthy_args CC_FAIL_ON_ERROR) )
124
- cc_cc_args +=( $( write_existing_args CC_GIT_SERVICE ) )
125
- cc_cc_args +=( $( write_existing_args CC_PARENT_SHA ) )
126
- cc_cc_args +=( $( write_existing_args CC_PR ) )
127
- cc_cc_args +=( $( write_existing_args CC_SHA ) )
128
- cc_cc_args +=( $( write_existing_args CC_SLUG ) )
130
+ cc_du_args +=( $( k_arg GIT_SERVICE ) $( v_arg GIT_SERVICE ) )
131
+ cc_du_args +=( $( k_arg PARENT_SHA ) $( v_arg PARENT_SHA ) )
132
+ cc_du_args +=( $( k_arg PR ) $( v_arg PR ) )
133
+ cc_du_args +=( $( k_arg SHA ) $( v_arg SHA ) )
134
+ cc_du_args +=( $( k_arg SLUG ) $( v_arg SLUG ) )
129
135
cc_create_report_args=()
130
- cc_cr_args+=( $( write_existing_args CC_CODE ) )
136
+ cc_cr_args+=( $( k_arg CODE ) $( v_arg CODE ) )
131
137
cc_cr_args+=( $( write_truthy_args CC_FAIL_ON_ERROR) )
132
- cc_cr_args+=( $( write_existing_args CC_GIT_SERVICE ) )
133
- cc_cr_args+=( $( write_existing_args CC_PR ) )
134
- cc_cr_args+=( $( write_existing_args CC_SHA ) )
135
- cc_cr_args+=( $( write_existing_args CC_SLUG ) )
138
+ cc_cr_args+=( $( k_arg GIT_SERVICE ) $( v_arg GIT_SERVICE ) )
139
+ cc_cr_args+=( $( k_arg PR ) $( v_arg PR ) )
140
+ cc_cr_args+=( $( k_arg SHA ) $( v_arg SHA ) )
141
+ cc_cr_args+=( $( k_arg SLUG ) $( v_arg SLUG ) )
136
142
cc_du_args=()
137
- cc_du_args+=( $( write_existing_args CC_ENV ) )
143
+ cc_du_args+=( $( k_arg ENV ) $( v_arg ENV ) )
138
144
OLDIFS=$IFS ; IFS=,
139
- cc_du_args+=( $( write_existing_args CC_BRANCH ) )
140
- cc_du_args+=( $( write_existing_args CC_BUILD ) )
141
- cc_du_args+=( $( write_existing_args CC_BUILD_URL ) )
142
- cc_du_args+=( $( write_existing_args CC_CODE ) )
143
- cc_du_args+=( $( write_existing_args CC_DIR ) )
145
+ cc_du_args+=( $( k_arg BRANCH ) $( v_arg BRANCH ) )
146
+ cc_du_args+=( $( k_arg BUILD ) $( v_arg BUILD ) )
147
+ cc_du_args+=( $( k_arg BUILD_URL ) $( v_arg BUILD_URL ) )
148
+ cc_du_args+=( $( k_arg CODE ) $( v_arg CODE ) )
149
+ cc_du_args+=( $( k_arg DIR ) $( v_arg DIR ) )
144
150
cc_du_args+=( $( write_truthy_args CC_DISABLE_FILE_FIXES) )
145
151
cc_du_args+=( $( write_truthy_args CC_DISABLE_SEARCH) )
146
152
cc_du_args+=( $( write_truthy_args CC_DRY_RUN) )
147
153
if [ -n " $CC_EXCLUDES " ];
148
154
then
149
155
for directory in $CC_EXCLUDES ; do
150
- cc_du_args+=( " --exclude " " $directory " )
156
+ cc_du_args+=( " --exclude" " $directory " )
151
157
done
152
158
fi
153
159
cc_du_args+=( $( write_truthy_args CC_FAIL_ON_ERROR) )
154
160
if [ -n " $CC_FILES " ];
155
161
then
156
162
for file in $CC_FILES ; do
157
- cc_du_args+=( " --file " " $file " )
163
+ cc_du_args+=( " --file" " $file " )
158
164
done
159
165
fi
160
166
if [ -n " $CC_FLAGS " ];
161
167
then
162
168
for flag in $CC_FLAGS ; do
163
- cc_du_args+=( " --flag " " $flag " )
169
+ cc_du_args+=( " --flag" " $flag " )
164
170
done
165
171
fi
166
- cc_du_args+=( $( write_existing_args CC_GCOV_ARGS ) )
167
- cc_du_args+=( $( write_existing_args CC_GCOV_EXECUTABLE ) )
168
- cc_du_args+=( $( write_existing_args CC_GCOV_IGNORE ) )
169
- cc_du_args+=( $( write_existing_args CC_GCOV_INCLUDE ) )
170
- cc_du_args+=( $( write_existing_args CC_GIT_SERVICE ) )
172
+ cc_du_args+=( $( k_arg GCOV_ARGS ) $( v_arg GCOV_ARGS ) )
173
+ cc_du_args+=( $( k_arg GCOV_EXECUTABLE ) $( v_arg GCOV_EXECUTABLE ) )
174
+ cc_du_args+=( $( k_arg GCOV_IGNORE ) $( v_arg GCOV_IGNORE ) )
175
+ cc_du_args+=( $( k_arg GCOV_INCLUDE ) $( v_arg GCOV_INCLUDE ) )
176
+ cc_du_args+=( $( k_arg GIT_SERVICE ) $( v_arg GIT_SERVICE ) )
171
177
cc_du_args+=( $( write_truthy_args CC_HANDLE_NO_REPORTS_FOUND) )
172
- cc_du_args+=( $( write_existing_args CC_JOB_CODE ) )
178
+ cc_du_args+=( $( k_arg JOB_CODE ) $( v_arg JOB_CODE ) )
173
179
cc_du_args+=( $( write_truthy_args CC_LEGACY) )
174
- cc_du_args+=( $( write_existing_args CC_NAME) )
175
- cc_du_args+=( $( write_existing_args CC_NETWORK_FILTER) )
176
- cc_du_args+=( $( write_existing_args CC_NETWORK_PREFIX) )
177
- cc_du_args+=( $( write_existing_args CC_NETWORK_ROOT_FOLDER) )
180
+ if [ -n " $CC_NAME " ];
181
+ then
182
+ cc_du_args+=( " --name" " $CC_NAME " )
183
+ fi
184
+ cc_du_args+=( $( k_arg NETWORK_FILTER) $( v_arg NETWORK_FILTER) )
185
+ cc_du_args+=( $( k_arg NETWORK_PREFIX) $( v_arg NETWORK_PREFIX) )
186
+ cc_du_args+=( $( k_arg NETWORK_ROOT_FOLDER) $( v_arg NETWORK_ROOT_FOLDER) )
178
187
if [ -n " $CC_PLUGINS " ];
179
188
then
180
189
for plugin in $CC_PLUGINS ; do
181
- cc_du_args+=( " --plugin " " $plugin " )
190
+ cc_du_args+=( " --plugin" " $plugin " )
182
191
done
183
192
fi
184
- cc_du_args+=( $( write_existing_args CC_PR ) )
185
- cc_du_args+=( $( write_existing_args CC_REPORT_TYPE ) )
186
- cc_du_args+=( $( write_existing_args CC_SHA ) )
187
- cc_du_args+=( $( write_existing_args CC_SLUG ) )
188
- cc_du_args+=( $( write_existing_args CC_SWIFT_PROJECT ) )
193
+ cc_du_args+=( $( k_arg PR ) $( v_arg PR ) )
194
+ cc_du_args+=( $( k_arg REPORT_TYPE ) $( v_arg REPORT_TYPE ) )
195
+ cc_du_args+=( $( k_arg SHA ) $( v_arg SHA ) )
196
+ cc_du_args+=( $( k_arg SLUG ) $( v_arg SLUG ) )
197
+ cc_du_args+=( $( k_arg SWIFT_PROJECT ) $( v_arg SWIFT_PROJECT ) )
189
198
IFS=$OLDIFS
190
199
unset NODE_OPTIONS
191
200
# See https://github.com/codecov/uploader/issues/475
@@ -210,7 +219,7 @@ if ! ./$cc_filename \
210
219
${cc_cli_args[*]} \
211
220
create-commit \
212
221
${token_arg[*]} \
213
- ${cc_cc_args[*]} ;
222
+ " ${cc_cc_args[@]} " ;
214
223
then
215
224
exit_if_error " Failed to create-commit"
216
225
fi
@@ -221,7 +230,7 @@ if ! ./$cc_filename \
221
230
${cc_cli_args[*]} \
222
231
create-report \
223
232
${token_arg[*]} \
224
- ${cc_cr_args[*]} ;
233
+ " ${cc_cr_args[@]} " ;
225
234
then
226
235
exit_if_error " Failed to create-report"
227
236
fi
@@ -232,7 +241,7 @@ if ! ./$cc_filename \
232
241
${cc_cli_args[*]} \
233
242
do-upload \
234
243
${token_arg[*]} \
235
- ${cc_du_args[*]} ;
244
+ " ${cc_du_args[@]} " ;
236
245
then
237
246
exit_if_error " Failed to upload"
238
247
fi
0 commit comments