Unverified Commit 92db54cc authored by Kubernetes Prow Robot's avatar Kubernetes Prow Robot Committed by GitHub

Merge pull request #73335 from oomichi/cleanup-hack

Add check-file-in-alphabetical-order for cleanup
parents 2fd8f8ae c32d1acb
...@@ -775,6 +775,23 @@ function kube::util::ensure-gnu-sed { ...@@ -775,6 +775,23 @@ function kube::util::ensure-gnu-sed {
fi fi
} }
# kube::util::check-file-in-alphabetical-order <file>
# Check that the file is in alphabetical order
#
function kube::util::check-file-in-alphabetical-order {
local failure_file="$1"
if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then
{
echo
echo "${failure_file} is not in alphabetical order. Please sort it:"
echo
echo " LC_ALL=C sort -o ${failure_file} ${failure_file}"
echo
} >&2
false
fi
}
# Some useful colors. # Some useful colors.
if [[ -z "${color_start-}" ]]; then if [[ -z "${color_start-}" ]]; then
declare -r color_start="\033[" declare -r color_start="\033["
......
...@@ -20,6 +20,7 @@ set -o pipefail ...@@ -20,6 +20,7 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh" source "${KUBE_ROOT}/hack/lib/init.sh"
source "${KUBE_ROOT}/hack/lib/util.sh"
kube::golang::verify_go_version kube::golang::verify_go_version
...@@ -49,16 +50,7 @@ array_contains () { ...@@ -49,16 +50,7 @@ array_contains () {
# Check that the file is in alphabetical order # Check that the file is in alphabetical order
failure_file="${KUBE_ROOT}/hack/.golint_failures" failure_file="${KUBE_ROOT}/hack/.golint_failures"
if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then kube::util::check-file-in-alphabetical-order "${failure_file}"
{
echo
echo "hack/.golint_failures is not in alphabetical order. Please sort it:"
echo
echo " LC_ALL=C sort -o hack/.golint_failures hack/.golint_failures"
echo
} >&2
false
fi
export IFS=$'\n' export IFS=$'\n'
# NOTE: when "go list -e ./..." is run within GOPATH, it turns the k8s.io/kubernetes # NOTE: when "go list -e ./..." is run within GOPATH, it turns the k8s.io/kubernetes
......
...@@ -20,6 +20,7 @@ set -o pipefail ...@@ -20,6 +20,7 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
source "${KUBE_ROOT}/hack/lib/init.sh" source "${KUBE_ROOT}/hack/lib/init.sh"
source "${KUBE_ROOT}/hack/lib/util.sh"
# required version for this script, if not installed on the host we will # required version for this script, if not installed on the host we will
# use the official docker image instead. keep this in sync with SHELLCHECK_IMAGE # use the official docker image instead. keep this in sync with SHELLCHECK_IMAGE
...@@ -79,16 +80,7 @@ done < <(find . -name "*.sh" \ ...@@ -79,16 +80,7 @@ done < <(find . -name "*.sh" \
# make sure known failures are sorted # make sure known failures are sorted
failure_file="${KUBE_ROOT}/hack/.shellcheck_failures" failure_file="${KUBE_ROOT}/hack/.shellcheck_failures"
if ! diff -u "${failure_file}" <(LC_ALL=C sort "${failure_file}"); then kube::util::check-file-in-alphabetical-order "${failure_file}"
{
echo
echo "hack/.shellcheck_failures is not in alphabetical order. Please sort it:"
echo
echo " LC_ALL=C sort -o hack/.shellcheck_failures hack/.shellcheck_failures"
echo
} >&2
false
fi
# load known failure files # load known failure files
failing_files=() failing_files=()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment