From 7100762afbc822b91806a6574658129fe0d23a7d Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 26 Feb 2021 08:58:40 -0500 Subject: [PATCH] Network prefix filter (#412) * Add new flag for network filtering * force * Update files --- SHA1SUM | 2 +- SHA256SUM | 2 +- SHA512SUM | 2 +- codecov | 25 ++++++++++++++++++------- tests/test | 16 ++++++++++++++++ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/SHA1SUM b/SHA1SUM index f1c2048d..8554d172 100644 --- a/SHA1SUM +++ b/SHA1SUM @@ -1 +1 @@ -4dc681475a004f8cb8c1d8cf7c5aff3bd53d615b codecov +20189261363b53e39287a46aa07352853646f17b codecov diff --git a/SHA256SUM b/SHA256SUM index 96dfa17d..0d2e6336 100644 --- a/SHA256SUM +++ b/SHA256SUM @@ -1 +1 @@ -ae4058f2f1f0d3f62e6a95e288616c2a3e9c8a4929d8cefd69e6c36da81d0963 codecov +54cce90506cc2f675a2dbd53cb6be3be0dc575ea74d873b8aa7c9d5fdaeb03e2 codecov diff --git a/SHA512SUM b/SHA512SUM index ffaba037..f50b210f 100644 --- a/SHA512SUM +++ b/SHA512SUM @@ -1 +1 @@ -6d01cca237aaf0627165e71d384dfc4f63b538fe463138f078e9a54b434350cf008bcd7dbf489d80985156d53475f9c1bb41b425320372d5028942cde795b0a7 codecov +b26e17183e97ef5c076f7788c3b3462fd7263b2e53bfffde5f6205dc596fdfe943ee83e04f6f04a060a74ead24ab59fe24aac8bec54cf1aa68af15b57e069795 codecov diff --git a/codecov b/codecov index db1f68e4..ccc66bd2 100755 --- a/codecov +++ b/codecov @@ -53,15 +53,16 @@ then git_root="." fi -url_o="" -pr_o="" +branch_o="" build_o="" commit_o="" +pr_o="" +prefix_o="" +network_filter_o="" search_in_o="" -tag_o="" -branch_o="" slug_o="" -prefix_o="" +tag_o="" +url_o="" git_ls_files_recurse_submodules_o="" package="bash" @@ -123,6 +124,10 @@ cat << EOF -e VAR,VAR2 + -k prefix Prefix filepaths to help resolve path fixing: https://github.com/codecov/support/issues/472 + + -i prefix Only include files in the network with a certain prefix. Useful for upload-specific path fixing + -X feature Toggle functionalities -X gcov Disable gcov @@ -168,7 +173,6 @@ cat << EOF -G GLOB Paths to include during gcov gathering -p dir Project root directory Also used when preparing gcov - -k prefix Prefix filepaths to help resolve path fixing: https://github.com/codecov/support/issues/472 -x gcovexe gcov executable to run. Defaults to 'gcov' -a gcovargs extra arguments to pass to gcov @@ -256,7 +260,7 @@ parse_yaml() { if [ $# != 0 ]; then - 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 + while getopts "a:A:b:B:cC:dD:e:f:F:g:G:hi:J:k:Kn:p:P:Q:q:r:R:s:S:t:T:u:U:vx:X:Zz:N:-" o do codecov_flags+=( "$o" ) case "$o" in @@ -334,6 +338,9 @@ $OPTARG" show_help exit 0; ;; + "i") + network_filter_o="$OPTARG" + ;; "J") ft_xcodellvm="1" ft_xcodeplist="0" @@ -1461,6 +1468,10 @@ then -type f -print 2>/dev/null || echo '') fi + if [ "$network_filter_o" != "" ]; + then + network=$(echo "$network" | grep -e "$network_filter_o/*") + fi if [ "$prefix_o" != "" ]; then network=$(echo "$network" | awk "{print \"$prefix_o/\"\$0}") diff --git a/tests/test b/tests/test index f2015016..7ec5ebb5 100755 --- a/tests/test +++ b/tests/test @@ -179,6 +179,22 @@ function test_env_env () { assertContains "$res" 'COMMIT=abc' } +function test_network_filter () { + reset + res=$(./codecov -d -i tests) + assertNotContains "$res" 'ignores/file.cpp' + assertNotContains "$res" 'SHA512SUM' + assertNotContains "$res" 'install.sh' + assertContains "$res" 'tests/test' + + reset + res=$(./codecov -d) + assertContains "$res" 'ignores/file.cpp' + assertContains "$res" 'SHA512SUM' + assertContains "$res" 'install.sh' + assertContains "$res" 'tests/test' +} + function test_slug_opt () { reset res=$(./codecov -dr myowner/myrepo | grep "https://codecov.io/")