[Git][NTPsec/ntpsec][master] Merge latest autorevision HEAD
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Dec 20 06:36:12 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
4a52effe by Matt Selsky at 2016-12-20T00:58:49-05:00
Merge latest autorevision HEAD
Fixes:
- Only use the committer date for git.
- Only use the `local` keyword where supported.
The latter issue broke the build on Solaris 11, where /bin/sh is ksh, and we
filed this as https://github.com/Autorevision/autorevision/issues/37
- - - - -
1 changed file:
- wafhelpers/autorevision.sh
Changes:
=====================================
wafhelpers/autorevision.sh
=====================================
--- a/wafhelpers/autorevision.sh
+++ b/wafhelpers/autorevision.sh
@@ -7,6 +7,8 @@
# autorevision - extracts metadata about the head version from your
# repository.
+# shellcheck disable=SC2154
+
# Usage message.
arUsage() {
tee >&2 << EOF
@@ -67,7 +69,7 @@ EOF
}
# Config
-ARVERSION="1.17"
+ARVERSION="1.18"
while getopts ":t:o:s:e:VfU" OPTION; do
case "${OPTION}" in
t)
@@ -115,6 +117,16 @@ elif [ ! -f "${CACHEFILE}" ] && [ "${CACHEFORCE}" = "1" ]; then
exit 1
fi
+# Only use the local keyword if it is there (Solaris we are looking at
+# you).
+if command -v local > /dev/null 2>&1; then
+ LOCAL="local"
+elif command -v typeset > /dev/null 2>&1; then
+ LOCAL="typeset"
+else
+ LOCAL=""
+fi
+
# Make sure that the path we are given is one we can source
# (dash, we are looking at you).
if [ ! -z "${CACHEFILE}" ] && ! echo "${CACHEFILE}" | grep -q '^\.*/'; then
@@ -128,7 +140,7 @@ GENERATED_HEADER="Generated by autorevision - do not hand-hack!"
# For git repos
# shellcheck disable=SC2039,SC2164,SC2155
gitRepo() {
- local oldPath="${PWD}"
+ ${LOCAL} oldPath="${PWD}"
cd "$(git rev-parse --show-toplevel)"
@@ -136,9 +148,11 @@ gitRepo() {
VCS_BASENAME="$(basename "${PWD}")"
- VCS_UUID="$(git rev-list --max-parents=0 --date-order --reverse HEAD 2>/dev/null | sed -n 1p)"
+ ${LOCAL} currentRev="$(git rev-parse HEAD)"
+
+ VCS_UUID="$(git rev-list --max-parents=0 --date-order --reverse "${currentRev}" 2>/dev/null | sed -n 1p)"
if [ -z "${VCS_UUID}" ]; then
- VCS_UUID="$(git rev-list --topo-order HEAD | tail -n 1)"
+ VCS_UUID="$(git rev-list --topo-order "${currentRev}" | tail -n 1)"
fi
# Is the working copy clean?
@@ -146,7 +160,7 @@ gitRepo() {
VCS_WC_MODIFIED="${?}"
# Enumeration of changesets
- VCS_NUM="$(git rev-list --count HEAD 2>/dev/null)"
+ VCS_NUM="$(git rev-list --count "${currentRev}" 2>/dev/null)"
if [ -z "${VCS_NUM}" ]; then
echo "warning: Counting the number of revisions may be slower due to an outdated git version less than 1.7.2.3. If something breaks, please update it." 1>&2
VCS_NUM="$(git rev-list HEAD | wc -l)"
@@ -155,21 +169,21 @@ gitRepo() {
# This may be a git-svn remote. If so, report the Subversion revision.
if [ -z "$(git config svn-remote.svn.url 2>/dev/null)" ]; then
# The full revision hash
- VCS_FULL_HASH="$(git rev-parse HEAD)"
+ VCS_FULL_HASH="$(git rev-parse "${currentRev}")"
# The short hash
- VCS_SHORT_HASH="$(git rev-parse --short "${VCS_FULL_HASH}")"
+ VCS_SHORT_HASH="$(git rev-parse --short "${currentRev}")"
else
# The git-svn revision number
- VCS_FULL_HASH="$(git svn find-rev HEAD)"
+ VCS_FULL_HASH="$(git svn find-rev "${currentRev}")"
VCS_SHORT_HASH="${VCS_FULL_HASH}"
fi
# Current branch
- VCS_BRANCH="$(git rev-parse --symbolic-full-name --verify "$(git name-rev --name-only --no-undefined HEAD 2>/dev/null)" 2>/dev/null | sed -e 's:refs/heads/::' | sed -e 's:refs/::')"
+ VCS_BRANCH="$(git rev-parse --symbolic-full-name --verify "$(git name-rev --name-only --no-undefined "${currentRev}" 2>/dev/null)" 2>/dev/null | sed -e 's:refs/heads/::' | sed -e 's:refs/::')"
# Cache the description
- local DESCRIPTION="$(git describe --long --tags 2>/dev/null)"
+ ${LOCAL} DESCRIPTION="$(git describe --long --tags "${currentRev}" 2>/dev/null)"
# Current or last tag ancestor (empty if no tags)
VCS_TAG="$(echo "${DESCRIPTION}" | sed -e "s:-g${VCS_SHORT_HASH}\$::" -e 's:-[0-9]*$::')"
@@ -182,16 +196,16 @@ gitRepo() {
fi
# Date of the current commit
- VCS_DATE="$(TZ=UTC git show -s --date=iso-strict-local --pretty=format:%ad 2>/dev/null | sed -e 's|+00:00|Z|')"
+ VCS_DATE="$(TZ=UTC git show -s --date=iso-strict-local --pretty=format:%cd "${currentRev}" 2>/dev/null | sed -e 's|+00:00|Z|')"
if [ -z "${VCS_DATE}" ]; then
echo "warning: Action stamps require git version 2.7+." 1>&2
- VCS_DATE="$(git log -1 --pretty=format:%ci | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')"
- local ASdis="1"
+ VCS_DATE="$(git log -1 --pretty=format:%ci "${currentRev}" | sed -e 's: :T:' -e 's: ::' -e 's|+00:00|Z|')"
+ ${LOCAL} ASdis="1"
fi
# Action Stamp
if [ -z "${ASdis}" ]; then
- VCS_ACTION_STAMP="${VCS_DATE}!$(git show -s --pretty=format:%cE)"
+ VCS_ACTION_STAMP="${VCS_DATE}!$(git show -s --pretty=format:%cE "${currentRev}")"
else
VCS_ACTION_STAMP=""
fi
@@ -202,7 +216,7 @@ gitRepo() {
# For hg repos
# shellcheck disable=SC2039,SC2164
hgRepo() {
- local oldPath="${PWD}"
+ ${LOCAL} oldPath="${PWD}"
cd "$(hg root)"
@@ -255,7 +269,7 @@ hgRepo() {
# For bzr repos
# shellcheck disable=SC2039,SC2164
bzrRepo() {
- local oldPath="${PWD}"
+ ${LOCAL} oldPath="${PWD}"
cd "$(bzr root)"
@@ -305,17 +319,17 @@ bzrRepo() {
# For svn repos
# shellcheck disable=SC2039,SC2164,SC2155
svnRepo() {
- local oldPath="${PWD}"
+ ${LOCAL} oldPath="${PWD}"
VCS_TYPE="svn"
case "${PWD}" in
/*trunk*|/*branches*|/*tags*)
- local fn="${PWD}"
+ ${LOCAL} fn="${PWD}"
while [ "$(basename "${fn}")" != 'trunk' ] && [ "$(basename "${fn}")" != 'branches' ] && [ "$(basename "${fn}")" != 'tags' ] && [ "$(basename "${fn}")" != '/' ]; do
- local fn="$(dirname "${fn}")"
+ ${LOCAL} fn="$(dirname "${fn}")"
done
- local fn="$(dirname "${fn}")"
+ ${LOCAL} fn="$(dirname "${fn}")"
if [ "${fn}" = '/' ]; then
VCS_BASENAME="$(basename "${PWD}")"
else
@@ -328,7 +342,7 @@ svnRepo() {
VCS_UUID="$(svn info --xml | sed -n -e 's:<uuid>::' -e 's:</uuid>::p')"
# Cache svnversion output
- local SVNVERSION="$(svnversion)"
+ ${LOCAL} SVNVERSION="$(svnversion)"
# Is the working copy clean?
echo "${SVNVERSION}" | grep -q "M"
@@ -362,8 +376,8 @@ svnRepo() {
# Current branch
case "${PWD}" in
/*trunk*|/*branches*|/*tags*)
- local lastbase=""
- local fn="${PWD}"
+ ${LOCAL} lastbase=""
+ ${LOCAL} fn="${PWD}"
while :
do
base="$(basename "${fn}")"
@@ -377,8 +391,8 @@ svnRepo() {
VCS_BRANCH=""
break
fi
- local lastbase="${base}"
- local fn="$(dirname "${fn}")"
+ ${LOCAL} lastbase="${base}"
+ ${LOCAL} fn="$(dirname "${fn}")"
done
;;
*) VCS_BRANCH="" ;;
@@ -1009,7 +1023,7 @@ EOF
# For C++ Header output
# shellcheck disable=SC2155,SC2039
hppOutput() {
- local NAMESPACE="$(echo "${VCS_BASENAME}" | sed -e 's:_::g' | tr '[:lower:]' '[:upper:]')"
+ ${LOCAL} NAMESPACE="$(echo "${VCS_BASENAME}" | sed -e 's:_::g' | tr '[:lower:]' '[:upper:]')"
tee << EOF
/* ${GENERATED_HEADER} */
@@ -1102,8 +1116,8 @@ EOF
# Count path segments
# shellcheck disable=SC2039
pathSegment() {
- local pathz="${1}"
- local depth="0"
+ ${LOCAL} pathz="${1}"
+ ${LOCAL} depth="0"
if [ ! -z "${pathz}" ]; then
# Continue until we are at / or there are no path separators left.
@@ -1118,10 +1132,10 @@ pathSegment() {
# Largest of four numbers
# shellcheck disable=SC2039
multiCompare() {
- local larger="${1}"
- local numA="${2}"
- local numB="${3}"
- local numC="${4}"
+ ${LOCAL} larger="${1}"
+ ${LOCAL} numA="${2}"
+ ${LOCAL} numB="${3}"
+ ${LOCAL} numC="${4}"
[ "${numA}" -gt "${larger}" ] && larger="${numA}"
[ "${numB}" -gt "${larger}" ] && larger="${numB}"
@@ -1134,49 +1148,49 @@ multiCompare() {
repoTest() {
REPONUM="0"
if command -v git > /dev/null 2>&1; then
- local gitPath="$(git rev-parse --show-toplevel 2>/dev/null)"
- local gitDepth="$(pathSegment "${gitPath}")"
+ ${LOCAL} gitPath="$(git rev-parse --show-toplevel 2>/dev/null)"
+ ${LOCAL} gitDepth="$(pathSegment "${gitPath}")"
if [ ! -z "${gitPath}" ]; then
REPONUM="$((REPONUM+1))"
fi
else
- local gitDepth="0"
+ ${LOCAL} gitDepth="0"
fi
if command -v hg > /dev/null 2>&1; then
- local hgPath="$(hg root 2>/dev/null)"
- local hgDepth="$(pathSegment "${hgPath}")"
+ ${LOCAL} hgPath="$(hg root 2>/dev/null)"
+ ${LOCAL} hgDepth="$(pathSegment "${hgPath}")"
if [ ! -z "${hgPath}" ]; then
REPONUM="$((REPONUM+1))"
fi
else
- local hgDepth="0"
+ ${LOCAL} hgDepth="0"
fi
if command -v bzr > /dev/null 2>&1; then
- local bzrPath="$(bzr root 2>/dev/null)"
- local bzrDepth="$(pathSegment "${bzrPath}")"
+ ${LOCAL} bzrPath="$(bzr root 2>/dev/null)"
+ ${LOCAL} bzrDepth="$(pathSegment "${bzrPath}")"
if [ ! -z "${bzrPath}" ]; then
REPONUM="$((REPONUM+1))"
fi
else
- local bzrDepth="0"
+ ${LOCAL} bzrDepth="0"
fi
if command -v svn > /dev/null 2>&1; then
- local stringz="<wcroot-abspath>"
- local stringx="</wcroot-abspath>"
- local svnPath="$(svn info --xml 2>/dev/null | sed -n -e "s:${stringz}::" -e "s:${stringx}::p")"
+ ${LOCAL} stringz="<wcroot-abspath>"
+ ${LOCAL} stringx="</wcroot-abspath>"
+ ${LOCAL} svnPath="$(svn info --xml 2>/dev/null | sed -n -e "s:${stringz}::" -e "s:${stringx}::p")"
# An old enough svn will not be able give us a path; default
# to 1 for that case.
if [ ! -z "${svnPath}" ]; then
- local svnDepth="$(pathSegment "${svnPath}")"
+ ${LOCAL} svnDepth="$(pathSegment "${svnPath}")"
REPONUM="$((REPONUM+1))"
elif [ -z "${svnPath}" ] && [ -d ".svn" ]; then
- local svnDepth="1"
+ ${LOCAL} svnDepth="1"
REPONUM="$((REPONUM+1))"
else
- local svnDepth="0"
+ ${LOCAL} svnDepth="0"
fi
else
- local svnDepth="0"
+ ${LOCAL} svnDepth="0"
fi
# Do not do more work then we have to.
@@ -1185,7 +1199,7 @@ repoTest() {
fi
# Figure out which repo is the deepest and use it.
- local wonRepo="$(multiCompare "${gitDepth}" "${hgDepth}" "${bzrDepth}" "${svnDepth}")"
+ ${LOCAL} wonRepo="$(multiCompare "${gitDepth}" "${hgDepth}" "${bzrDepth}" "${svnDepth}")"
if [ "${wonRepo}" = "${gitDepth}" ]; then
gitRepo
elif [ "${wonRepo}" = "${hgDepth}" ]; then
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/4a52effe75f9b618434267a3019178036dca377d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20161220/c5e2f8b7/attachment.html>
More information about the vc
mailing list