...

Text file src/github.com/cert-manager/issuer-lib/make/_shared/generate-verify/util/verify.sh

Documentation: github.com/cert-manager/issuer-lib/make/_shared/generate-verify/util

     1#!/usr/bin/env bash
     2
     3# Copyright 2023 The cert-manager Authors.
     4#
     5# Licensed under the Apache License, Version 2.0 (the "License");
     6# you may not use this file except in compliance with the License.
     7# You may obtain a copy of the License at
     8#
     9#     http://www.apache.org/licenses/LICENSE-2.0
    10#
    11# Unless required by applicable law or agreed to in writing, software
    12# distributed under the License is distributed on an "AS IS" BASIS,
    13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14# See the License for the specific language governing permissions and
    15# limitations under the License.
    16
    17# Verify that the supplied command does not make any changes to the repository.
    18#
    19# This is called from the Makefile to verify that all code generation scripts
    20# have been run and that their changes have been committed to the repository.
    21#
    22# Runs any of the scripts or Make targets in this repository, after making a
    23# copy of the repository, then reports any changes to the files in the copy.
    24
    25# For example:
    26#
    27#  make verify-helm-chart-update || \
    28#    make helm-chart-update
    29#
    30set -o errexit
    31set -o nounset
    32set -o pipefail
    33
    34projectdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../.." && pwd )"
    35
    36cd "${projectdir}"
    37
    38# Use short form arguments here to support BSD/macOS. `-d` instructs
    39# it to make a directory, `-t` provides a prefix to use for the directory name.
    40tmp="$(mktemp -d /tmp/verify.sh.XXXXXXXX)"
    41
    42cleanup() {
    43    rm -rf "${tmp}"
    44}
    45trap "cleanup" EXIT SIGINT
    46
    47rsync -aEq "${projectdir}/." "${tmp}" --exclude "_bin/"
    48pushd "${tmp}" >/dev/null
    49
    50"$@"
    51
    52popd >/dev/null
    53
    54if ! diff \
    55    --exclude=".git" \
    56    --exclude="_bin" \
    57    --new-file --unified --show-c-function --recursive "${projectdir}" "${tmp}"
    58then
    59    echo
    60    echo "Project '${projectdir}' is out of date."
    61    echo "Please run '${*}'"
    62    exit 1
    63fi

View as plain text