You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/11/30 17:01:47 UTC
[trafficserver] 02/02: updates pre-commit hook to use specific
clang-format
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 37781a78e574576639e1bc61ce83554dce9f83a7
Author: Derek Dagit <de...@oath.com>
AuthorDate: Tue Sep 12 17:53:47 2017 +0000
updates pre-commit hook to use specific clang-format
(cherry picked from commit dc1202e69eb07284f61ad8a43bdef5e9fe941da8)
Conflicts:
tools/clang-format.sh
---
tools/clang-format.sh | 104 +++++++++++++++++++++++++++-----------------------
tools/git/pre-commit | 4 +-
2 files changed, 60 insertions(+), 48 deletions(-)
diff --git a/tools/clang-format.sh b/tools/clang-format.sh
index 5eba5ad..b7da024 100755
--- a/tools/clang-format.sh
+++ b/tools/clang-format.sh
@@ -18,64 +18,74 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-set -e # exit on error
-
+# Update the PKGDATE with the new version date when making a new clang-format binary package.
PKGDATE="20160415"
-DIR=${1:-.}
-ROOT=${ROOT:-$(cd $(dirname $0) && git rev-parse --show-toplevel)/.git/fmt/${PKGDATE}}
-PACKAGE="clang-format-${PKGDATE}.tar.bz2"
-VERSION="clang-format version 3.9.0 (trunk 265913)"
-URL=${URL:-https://ci.trafficserver.apache.org/bintray/${PACKAGE}}
+function main() {
+ set -e # exit on error
+ ROOT=${ROOT:-$(cd $(dirname $0) && git rev-parse --show-toplevel)/.git/fmt/${PKGDATE}}
-TAR=${TAR:-tar}
-CURL=${CURL:-curl}
+ DIR=${1:-.}
+ PACKAGE="clang-format-${PKGDATE}.tar.bz2"
+ VERSION="clang-format version 3.9.0 (trunk 265913)"
-# default to using native sha1sum command when available
-if [ $(which sha1sum) ] ; then
- SHASUM=${SHASUM:-sha1sum}
-else
- SHASUM=${SHASUM:-shasum}
-fi
+ URL=${URL:-https://ci.trafficserver.apache.org/bintray/${PACKAGE}}
+
+ TAR=${TAR:-tar}
+ CURL=${CURL:-curl}
-ARCHIVE=$ROOT/$(basename ${URL})
+ # default to using native sha1sum command when available
+ if [ $(which sha1sum) ] ; then
+ SHASUM=${SHASUM:-sha1sum}
+ else
+ SHASUM=${SHASUM:-shasum}
+ fi
-case $(uname -s) in
-Darwin)
- FORMAT=${FORMAT:-${ROOT}/clang-format/clang-format.osx}
- ;;
-Linux)
- FORMAT=${FORMAT:-${ROOT}/clang-format/clang-format.linux}
- ;;
-*)
- echo "Leif needs to build a clang-format for $(uname -s)"
- exit 2
-esac
+ ARCHIVE=$ROOT/$(basename ${URL})
-mkdir -p ${ROOT}
+ case $(uname -s) in
+ Darwin)
+ FORMAT=${FORMAT:-${ROOT}/clang-format/clang-format.osx}
+ ;;
+ Linux)
+ FORMAT=${FORMAT:-${ROOT}/clang-format/clang-format.linux}
+ ;;
+ *)
+ echo "Leif needs to build a clang-format for $(uname -s)"
+ exit 2
+ esac
-# Note that the two spaces between the hash and ${ARCHIVE) is needed
-if [ ! -e ${FORMAT} -o ! -e ${ROOT}/${PACKAGE} ] ; then
- ${CURL} -L --progress-bar -o ${ARCHIVE} ${URL}
- ${TAR} -x -C ${ROOT} -f ${ARCHIVE}
- cat > ${ROOT}/sha1 << EOF
+ mkdir -p ${ROOT}
+
+ # Note that the two spaces between the hash and ${ARCHIVE) is needed
+ if [ ! -e ${FORMAT} -o ! -e ${ROOT}/${PACKAGE} ] ; then
+ ${CURL} -L --progress-bar -o ${ARCHIVE} ${URL}
+ ${TAR} -x -C ${ROOT} -f ${ARCHIVE}
+ cat > ${ROOT}/sha1 << EOF
d5558924377a6ad5799956cec5b37d4e421e2156 ${ARCHIVE}
EOF
- ${SHASUM} -c ${ROOT}/sha1
- chmod +x ${FORMAT}
-fi
+ ${SHASUM} -c ${ROOT}/sha1
+ chmod +x ${FORMAT}
+ fi
+
+ # Make sure we only run this with our exact version
+ ver=$(${FORMAT} --version)
+ if [ "$ver" != "$VERSION" ]; then
+ echo "Wrong version of clang-format!"
+ echo "See https://bintray.com/apache/trafficserver/clang-format-tools/view for a newer version,"
+ echo "or alternatively, undefine the FORMAT environment variable"
+ exit 1
+ else
+ for file in $(find $DIR -iname \*.[ch] -o -iname \*.cc); do
+ echo $file
+ ${FORMAT} -i $file
+ done
+ fi
+}
-# Make sure we only run this with our exact version
-ver=$(${FORMAT} --version)
-if [ "$ver" != "$VERSION" ]; then
- echo "Wrong version of clang-format!"
- echo "See https://bintray.com/apache/trafficserver/clang-format-tools/view for a newer version,"
- echo "or alternatively, undefine the FORMAT environment variable"
- exit 1
+if [[ "$(basename -- "$0")" == 'clang-format.sh' ]]; then
+ main "$@"
else
- for file in $(find $DIR -iname \*.[ch] -o -iname \*.cc); do
- echo $file
- ${FORMAT} -i $file
- done
+ ROOT=${ROOT:-$(git rev-parse --show-toplevel)/.git/fmt/${PKGDATE}}
fi
diff --git a/tools/git/pre-commit b/tools/git/pre-commit
index 3e9eca5..3aee8e7 100755
--- a/tools/git/pre-commit
+++ b/tools/git/pre-commit
@@ -18,7 +18,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-ROOT=$(git rev-parse --show-toplevel)/.git/fmt
+GIT_TOP="$(git rev-parse --show-toplevel)"
+source "$GIT_TOP/tools/clang-format.sh"
+
case $(uname -s) in
Darwin)
FORMAT=${FORMAT:-${ROOT}/clang-format/clang-format.osx}
--
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.