From 457b9d365a98239808c47ffc0ba4ac08832925a6 Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Mon, 14 Mar 2016 12:56:13 -0700 Subject: [PATCH] Make has_changes_against_upstream_branch detect uncommitted changes --- hack/lib/util.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 86051b6afa1..a287548e3ca 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -332,13 +332,20 @@ kube::util::has_changes_against_upstream_branch() { echo "Checking for '${pattern}' changes against '${full_branch}'" # make sure the branch is valid, otherwise the check will pass erroneously. if ! git describe "${full_branch}" >/dev/null; then + # abort! exit 1 fi # notice this uses ... to find the first shared ancestor - if ! git diff --name-only "${full_branch}...HEAD" | grep "${pattern}" > /dev/null; then - echo "No '${pattern}' changes detected." - return 1 + if git diff --name-only "${full_branch}...HEAD" | grep "${pattern}" > /dev/null; then + return 0 fi + # also check for pending changes + if git status --porcelain | grep "${pattern}" > /dev/null; then + echo "Detected '${pattern}' uncommitted changes." + return 0 + fi + echo "No '${pattern}' changes detected." + return 1 } # ex: ts=2 sw=2 et filetype=sh