@@ -28,6 +28,7 @@ ddp="$HOME/Library/Developer/Xcode/DerivedData"
2828xp=" "
2929files=" "
3030save_to=" "
31+ direct_file_upload=" "
3132cacert=" $CODECOV_CA_BUNDLE "
3233gcov_ignore=" -not -path './bower_components/**' -not -path './node_modules/**' -not -path './vendor/**'"
3334gcov_include=" "
@@ -146,6 +147,9 @@ cat << EOF
146147 -F ui,chrome This upload is Chrome - UI tests
147148
148149 -c Move discovered coverage reports to the trash
150+ -z FILE Upload specified file directly to Codecov and bypass all report generation.
151+ This is inteded to be used only with a pre-formatted Codecov report and is not
152+ expected to work under any other circumstances.
149153 -Z Exit with 1 if not successful. Default will Exit with 0
150154
151155 -- xcode --
@@ -248,10 +252,9 @@ parse_yaml() {
248252 }'
249253}
250254
251-
252255if [ $# != 0 ];
253256then
254- while getopts " a:A:b:B:cC:dD:e:f:F:g:G:hJ:k:Kn:p:P:Q:q:r:R:s:S:t:T:u:U:vx:X:ZN :-" o
257+ while getopts " a:A:b:B:cC:dD:e:f:F:g:G:hJ:k:Kn:p:P:Q:q:r:R:s:S:t:T:u:U:vx:X:Zz:N :-" o
255258 do
256259 codecov_flags+=( " $o " )
257260 case " $o " in
@@ -451,6 +454,17 @@ $OPTARG"
451454 " Z" )
452455 exit_with=1
453456 ;;
457+ " z" )
458+ direct_file_upload=" $OPTARG "
459+ ft_gcov=" 0"
460+ ft_coveragepy=" 0"
461+ ft_fix=" 0"
462+ ft_search=" 0"
463+ ft_network=" 0"
464+ ft_xcodellvm=" 0"
465+ ft_gcovout=" 0"
466+ include_cov=" "
467+ ;;
454468 * )
455469 echo -e " ${r} Unexpected flag not supported${x} "
456470 ;;
@@ -471,16 +485,19 @@ say "
471485
472486# check for installed tools
473487# git/hg
474- if [ -x " $( command -v git ) " ];
488+ if [ " $direct_file_upload " = " " ];
475489then
476- say " $b ==>$x $( git --version) found"
477- else
478- say " $y ==>$x git not installed, testing for mercurial"
479- if [ -x " $( command -v hg) " ];
490+ if [ -x " $( command -v git) " ];
480491 then
481- say " $b ==>$x $( hg --version) found"
492+ say " $b ==>$x $( git --version) found"
482493 else
483- say " $r ==>$x git nor mercurial are installed. Uploader may fail or have unintended consequences"
494+ say " $y ==>$x git not installed, testing for mercurial"
495+ if [ -x " $( command -v hg) " ];
496+ then
497+ say " $b ==>$x $( hg --version) found"
498+ else
499+ say " $r ==>$x git nor mercurial are installed. Uploader may fail or have unintended consequences"
500+ fi
484501 fi
485502fi
486503# curl
@@ -1373,6 +1390,9 @@ $PWD/coverage.xml"
13731390elif [ " $include_cov " != " " ];
13741391then
13751392 files=$( eval " find $search_in -type f \( ${include_cov: 5} \)$exclude_cov 2>/dev/null" || echo ' ' )
1393+ elif [ " $direct_file_upload " != " " ];
1394+ then
1395+ files=$direct_file_upload
13761396fi
13771397
13781398num_of_files=$( echo " $files " | wc -l | tr -d ' ' )
@@ -1442,6 +1462,7 @@ cleanup() {
14421462
14431463trap cleanup INT ABRT TERM
14441464
1465+
14451466if [ " $env " != " " ];
14461467then
14471468 inc_env=" "
@@ -1455,13 +1476,16 @@ then
14551476"
14561477 fi
14571478 done
1458-
1459- echo " $inc_env <<<<<< ENV" >> " $upload_file "
1479+ echo " $inc_env <<<<<< ENV" >> " $upload_file "
14601480fi
14611481
14621482# Append git file list
14631483# write discovered yaml location
1464- echo " $yaml " >> " $upload_file "
1484+ if [ " $direct_file_upload " = " " ];
1485+ then
1486+ echo " $yaml " >> " $upload_file "
1487+ fi
1488+
14651489if [ " $ft_network " == " 1" ];
14661490then
14671491 i=" woff|eot|otf" # fonts
@@ -1473,70 +1497,78 @@ then
14731497 then
14741498 i=" $i |html"
14751499 fi
1476-
14771500 echo " $network " | grep -vwE " ($i )$" >> " $upload_file "
14781501fi
14791502echo " <<<<<< network" >> " $upload_file "
14801503
1481- fr=0
1482- say " ${e} ==> ${x} Reading reports "
1483- while IFS= ' ' read -r file ;
1484- do
1485- # read the coverage file
1486- if [ " $( echo " $file " | tr -d ' ' ) " != ' ' ] ;
1487- then
1488- if [ -f " $file " ];
1504+ if [ " $direct_file_upload " = " " ] ;
1505+ then
1506+ fr=0
1507+ say " ${e} ==> ${x} Reading reports "
1508+ while IFS= ' ' read -r file;
1509+ do
1510+ # read the coverage file
1511+ if [ " $( echo " $file " | tr -d ' ' ) " != ' ' ];
14891512 then
1490- report_len=$( wc -c < " $file " )
1491- if [ " $report_len " -ne 0 ];
1513+ if [ -f " $file " ];
14921514 then
1493- say " ${g} +${x} $file ${e} bytes=$( echo " $report_len " | tr -d ' ' ) ${x} "
1494- # append to to upload
1495- _filename=$( basename " $file " )
1496- if [ " ${_filename##* .} " = ' gcov' ];
1515+ report_len=$( wc -c < " $file " )
1516+ if [ " $report_len " -ne 0 ];
14971517 then
1498- {
1499- echo " # path=$( echo " $file .reduced" | sed " s|^$git_root /||" ) " ;
1500- # get file name
1501- head -1 " $file " ;
1502- } >> " $upload_file "
1503- # 1. remove source code
1504- # 2. remove ending bracket lines
1505- # 3. remove whitespace
1506- # 4. remove contextual lines
1507- # 5. remove function names
1508- awk -F' : *' ' {print $1":"$2":"}' " $file " \
1509- | sed ' \/: *} *$/d' \
1510- | sed ' s/^ *//' \
1511- | sed ' /^-/d' \
1512- | sed ' s/^function.*/func/' >> " $upload_file "
1518+ say " ${g} +${x} $file ${e} bytes=$( echo " $report_len " | tr -d ' ' ) ${x} "
1519+ # append to to upload
1520+ _filename=$( basename " $file " )
1521+ if [ " ${_filename##* .} " = ' gcov' ];
1522+ then
1523+ {
1524+ echo " # path=$( echo " $file .reduced" | sed " s|^$git_root /||" ) " ;
1525+ # get file name
1526+ head -1 " $file " ;
1527+ } >> " $upload_file "
1528+ # 1. remove source code
1529+ # 2. remove ending bracket lines
1530+ # 3. remove whitespace
1531+ # 4. remove contextual lines
1532+ # 5. remove function names
1533+ awk -F' : *' ' {print $1":"$2":"}' " $file " \
1534+ | sed ' \/: *} *$/d' \
1535+ | sed ' s/^ *//' \
1536+ | sed ' /^-/d' \
1537+ | sed ' s/^function.*/func/' >> " $upload_file "
1538+ else
1539+ {
1540+ echo " # path=${file// ^$git_root / ||} " ;
1541+ cat " $file " ;
1542+ } >> " $upload_file "
1543+ fi
1544+ echo " <<<<<< EOF" >> " $upload_file "
1545+ fr=1
1546+ if [ " $clean " = " 1" ];
1547+ then
1548+ rm " $file "
1549+ fi
15131550 else
1514- {
1515- echo " # path=${file// ^$git_root / ||} " ;
1516- cat " $file " ;
1517- } >> " $upload_file "
1518- fi
1519- echo " <<<<<< EOF" >> " $upload_file "
1520- fr=1
1521- if [ " $clean " = " 1" ];
1522- then
1523- rm " $file "
1551+ say " ${r} -${x} Skipping empty file $file "
15241552 fi
15251553 else
1526- say " ${r} -${x} Skipping empty file $file "
1554+ say " ${r} -${x} file not found at $file "
15271555 fi
1528- else
1529- say " ${r} -${x} file not found at $file "
15301556 fi
1531- fi
1532- done <<< " $(echo -e " $files " )"
1557+ done <<< " $(echo -e " $files " )"
15331558
1534- if [ " $fr " = " 0" ];
1535- then
1536- say " ${r} -->${x} No coverage data found."
1537- say " Please visit ${b} http://docs.codecov.io/docs/supported-languages${x} "
1538- say " search for your projects language to learn how to collect reports."
1539- exit ${exit_with} ;
1559+ if [ " $fr " = " 0" ];
1560+ then
1561+ say " ${r} -->${x} No coverage data found."
1562+ say " Please visit ${b} http://docs.codecov.io/docs/supported-languages${x} "
1563+ say " search for your projects language to learn how to collect reports."
1564+ exit ${exit_with} ;
1565+ fi
1566+ else
1567+ cp " $direct_file_upload " " $upload_file "
1568+ if [ " $clean " = " 1" ];
1569+ then
1570+ rm " $direct_file_upload "
1571+ fi
15401572fi
15411573
15421574if [ " $ft_fix " = " 1" ];
@@ -1725,7 +1757,7 @@ else
17251757 if [ " $save_to " != " " ];
17261758 then
17271759 say " ${e} ==>${x} Copying upload file to ${save_to} "
1728- mkdir --parents " $save_to "
1760+ mkdir -p " $( dirname " $ save_to" ) "
17291761 cp " $upload_file " " $save_to "
17301762 fi
17311763
0 commit comments