From b09c6d56832eb1718c07d74abf3bc6ae3fe4e030 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:36:04 +0200 Subject: Adding upstream version 1.1.0. Signed-off-by: Daniel Baumann --- .../devtools/checklib.sh | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/devtools/checklib.sh (limited to 'dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/devtools/checklib.sh') diff --git a/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/devtools/checklib.sh b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/devtools/checklib.sh new file mode 100644 index 0000000..0b6095e --- /dev/null +++ b/dependencies/pkg/mod/golang.org/x/exp@v0.0.0-20220613132600-b0d781184e0d/devtools/checklib.sh @@ -0,0 +1,73 @@ +# Copyright 2021 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. + +# Library of useful bash functions and variables for presubmit checks. + +RED=; GREEN=; YELLOW=; NORMAL=; +MAXWIDTH=0 + +if tput setaf 1 >& /dev/null; then + RED=`tput setaf 1` + GREEN=`tput setaf 2` + YELLOW=`tput setaf 3` + NORMAL=`tput sgr0` + MAXWIDTH=$(( $(tput cols) - 2 )) +fi + +EXIT_CODE=0 + +info() { echo -e "${GREEN}$@${NORMAL}" 1>&2; } +warn() { echo -e "${YELLOW}$@${NORMAL}" 1>&2; } +err() { echo -e "${RED}$@${NORMAL}" 1>&2; EXIT_CODE=1; } + +die() { + err $@ + exit 1 +} + +dryrun=false + +# runcmd prints an info log describing the command that is about to be run, and +# then runs it. It sets EXIT_CODE to non-zero if the command fails, but does not exit +# the script. +runcmd() { + msg="$@" + if $dryrun; then + echo -e "${YELLOW}dryrun${GREEN}\$ $msg${NORMAL}" + return 0 + fi + # Truncate command logging for narrow terminals. + # Account for the 2 characters of '$ '. + if [[ $MAXWIDTH -gt 0 && ${#msg} -gt $MAXWIDTH ]]; then + msg="${msg::$(( MAXWIDTH - 3 ))}..." + fi + + echo -e "$@\n" 1>&2; + $@ || err "command failed" +} + +# check_header checks that all given files contain the standard header for Go +# projects. +check_header() { + if [[ "$@" != "" ]]; then + for FILE in $@ + do + line="$(head -4 $FILE)" + if [[ ! $line == *"The Go Authors. All rights reserved."* ]] && + [[ ! $line == "// DO NOT EDIT. This file was copied from" ]]; then + err "missing license header: $FILE" + fi + done + fi +} + +# ensure_go_binary verifies that a binary exists in $PATH corresponding to the +# given go-gettable URI. If no such binary exists, it is fetched via `go install`. +ensure_go_binary() { + local binary=$(basename $1) + if ! [ -x "$(command -v $binary)" ]; then + info "Installing: $1" + go install $1 + fi +} -- cgit v1.2.3