зеркало из https://github.com/golang/pkgsite.git
all.bash: factor out functions
Change-Id: Ibc54f17163145bb6d3a268f5ccdfc539a8510d9e Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/543857 Reviewed-by: Julie Qiu <julieqiu@google.com>
This commit is contained in:
Родитель
10519dc468
Коммит
8f3e11f3f4
36
all.bash
36
all.bash
|
@ -3,28 +3,7 @@
|
|||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
if [ -t 1 ] && which tput >/dev/null 2>&1; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
NORMAL=""
|
||||
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; }
|
||||
|
||||
if [[ ! -f ./all.bash ]]; then
|
||||
err "all.bash must be run from the repo root directory"
|
||||
exit 1
|
||||
fi
|
||||
source devtools/lib.sh || { echo "Are you at repo root?"; exit 1; }
|
||||
|
||||
warnout() {
|
||||
while read line; do
|
||||
|
@ -78,19 +57,6 @@ ensure_go_binary() {
|
|||
fi
|
||||
}
|
||||
|
||||
# runcmd prints an info log describing the command that is about to be run, and
|
||||
# then runs it. It exits the script if the command fails.
|
||||
runcmd() {
|
||||
msg="$@"
|
||||
# Truncate command logging for narrow terminals. Here a length of 71
|
||||
# characters is checked to allow for 9 characters of 'Running: '.
|
||||
if [[ ${#msg} -gt 71 ]]; then
|
||||
msg="${msg::68}..."
|
||||
fi
|
||||
info "Running: $msg"
|
||||
$@ || err "command failed"
|
||||
}
|
||||
|
||||
# check_headers checks that all source files that have been staged in this
|
||||
# commit, and all other non-third-party files in the repo, have a license
|
||||
# header.
|
||||
|
|
|
@ -94,7 +94,7 @@ func (s *Server) handlePackageDetails(w http.ResponseWriter, r *http.Request) {
|
|||
s.servePage(w, settings.TemplateName, page)
|
||||
}
|
||||
|
||||
// processPackageOrModulePath handles logic common to the intial phase of handling both packages and
|
||||
// processPackageOrModulePath handles logic common to the initial phase of handling both packages and
|
||||
// modules: fetching information about the package or module.
|
||||
// It parses urlPath into an import path and version, then calls the get function with those values.
|
||||
// If get fails because the version cannot be found, processPackageOrModulePath calls get again
|
||||
|
|
Загрузка…
Ссылка в новой задаче