From ecb2d86bdebe709d8ded7233a2fc955ca06006b2 Mon Sep 17 00:00:00 2001 From: rupor-github Date: Mon, 13 Mar 2023 11:49:30 -0400 Subject: [PATCH] Only run trivy check in git hook if we have anything to push --- cmake/pre-push | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/pre-push b/cmake/pre-push index 8941685..769d750 100755 --- a/cmake/pre-push +++ b/cmake/pre-push @@ -18,6 +18,11 @@ if [[ $? != 0 ]]; then exit 1 fi -# without the --exit-code 1 flag - trivy always exists with 0 cd @PROJECT_SOURCE_DIR@ +# Check if we actually have commits to push +commits=`git log @{u}..` +if [ -z "$commits" ]; then + exit 0 +fi +# without the --exit-code 1 flag - trivy always exists with 0 ${scanner} --exit-code 1 fs --ignore-unfixed .