From e2756edd72f19d156a0bb499f38cc7912a6c9810 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Mon, 15 Feb 2016 13:44:28 -0800 Subject: [PATCH 01/14] Test all crates and format on pre-commit --- hooks/pre-commit | 8 ++++++++ hooks/pre-push | 27 ++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 5103749..02d11c0 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -52,3 +52,11 @@ fi # If there are whitespace errors, print the offending file names and fail. exec git diff-index --check --cached $against -- + +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function cargo_format() { + echo ${YELLOW}[PRECOMMIT]${NC} Formatting $1 ... + cargo fmt --manifest-path $1/Cargo.toml &>/dev/null +} diff --git a/hooks/pre-push b/hooks/pre-push index 9880510..69df4b3 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -17,18 +17,23 @@ then exit 1 fi -printf "${YELLOW}[PRESUBMIT]${NC} Running tests ... " - TEST_RESULT=0 -cargo test --manifest-path tarpc/Cargo.toml &>/dev/null -if [ "$?" != "0" ]; -then - printf "${RED}FAILED${NC}" - TEST_RESULT=1 -else - printf "${GREEN}ok${NC}" -fi -printf "\n" + +function cargo_test() { + printf "${YELLOW}[PREPUSH]${NC} Testing $1 ... " + cargo test --manifest-path $1/Cargo.toml &>/dev/null + if [ "$?" != "0" ]; + then + printf "${RED}FAILED${NC}" + TEST_RESULT=1 + else + printf "${GREEN}ok${NC}" + fi + printf "\n" +} + +cargo_test tarpc +cargo_test tarpc_examples RESULT=0 if [ "$TEST_RESULT" == "1" ]; From 1f30bb9ba6a1e8b89ce350218114075dc8642be4 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Mon, 15 Feb 2016 13:58:42 -0800 Subject: [PATCH 02/14] Remove the install hooks script --- tarpc/install-hooks.sh | 8 -------- 1 file changed, 8 deletions(-) delete mode 100755 tarpc/install-hooks.sh diff --git a/tarpc/install-hooks.sh b/tarpc/install-hooks.sh deleted file mode 100755 index 15a1b9d..0000000 --- a/tarpc/install-hooks.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2016 Google Inc. All Rights Reserved. -# -# Licensed under the MIT License, . -# This file may not be copied, modified, or distributed except according to those terms. - -#!/bin/sh -ln -s ../../hooks/pre-commit .git/hooks/pre-commit -ln -s ../../hooks/pre-push .git/hooks/pre-push From 7b196400b8486fb2353a13585cdf6917f8337021 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Mon, 15 Feb 2016 17:28:16 -0800 Subject: [PATCH 03/14] Revamp push hook 1. Create environment variables for options 3. Use multirust to test different toolchains. If multirust isn't installed, use current toolchain. --- hooks/pre-push | 92 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 11 deletions(-) diff --git a/hooks/pre-push b/hooks/pre-push index 69df4b3..c76c0fb 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -3,6 +3,26 @@ # Licensed under the MIT License, . # This file may not be copied, modified, or distributed except according to those terms. +# Pre-push hook for the tarpc repository. To use this hook, copy it to .git/hooks in your repository +# root. +# +# This hook runs tests to make sure only working code is being pushed. If present, multirust is used +# to build and test the code on the appropriate toolchains. The working copy must not contain +# uncommitted changes, since the script currently just runs cargo build/test in the working copy. +# +# There are a few options that can be set by setting environment variables. +# +# - TARPC_ALLOW_DIRTY, default = 0 +# +# Setting this variable to 1 will run tests even though there are code changes in the working +# copy. Set to 0 by default, since the intent is to test the code that's being pushed, not changes +# still in the working copy. +# +# - TARPC_USE_CURRENT_TOOLCHAIN, default = 0 +# +# Setting this variable to 1 will just run cargo build and cargo test, rather than running +# stable/beta/nightly. + #!/bin/sh RED='\033[0;31m' @@ -10,30 +30,80 @@ GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color +PREFIX="${GREEN}[PREPUSH]${NC}" +FAILURE="${RED}FAILED${NC}" +WARNING="${RED}[WARNING]${NC}" +SUCCESS="${GREEN}ok${NC}" + +printf "${PREFIX} Clean working copy ... " git diff --exit-code &>/dev/null -if [ "$?" != 0 ]; +if [ "$?" == 0 ]; then - echo ${RED}ERROR${NC} You have uncommitted changes please commit or stash them before pushing so that I can run tests! - exit 1 + printf "${SUCCESS}\n" +else + printf "${FAILURE}\n" + if [ "${TARPC_ALLOW_DIRTY}" == "1" ] + then + echo ${WARNING} Running with unclean working directory + else + exit 1 + fi fi TEST_RESULT=0 -function cargo_test() { - printf "${YELLOW}[PREPUSH]${NC} Testing $1 ... " - cargo test --manifest-path $1/Cargo.toml &>/dev/null +# args: +# 1 - cargo command to run (build/test) +# 2 - directory name of crate to build +# 3 - rust toolchain (nightly/stable/beta) +function run_cargo() { + if [ "$1" == "build" ] + then + VERB=Building + else + VERB=Testing + fi + if [ "$3" != "" ] + then + printf "${PREFIX} $VERB $2 on $3 ... " + multirust run $3 cargo $1 --manifest-path $2/Cargo.toml &>/dev/null + else + printf "${PREFIX} $VERB $2 ... " + cargo $1 --manifest-path $2/Cargo.toml &>/dev/null + fi if [ "$?" != "0" ]; then - printf "${RED}FAILED${NC}" + printf "${FAILURE}\n" + #printf "${OUTPUT}\n" TEST_RESULT=1 else - printf "${GREEN}ok${NC}" + printf "${SUCCESS}\n" fi - printf "\n" } -cargo_test tarpc -cargo_test tarpc_examples +printf "${PREFIX} Checking for multirust ... " +command -v multirust &>/dev/null +if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; +then + printf "${SUCCESS}\n" + + # No need to build on nightly, the tests will do that + run_cargo build tarpc stable + run_cargo build tarpc beta + + run_cargo build tarpc_examples stable + run_cargo build tarpc_examples beta + + # We still rely on some nightly stuff for tests + run_cargo test tarpc nightly + run_cargo test tarpc_examples nightly +else + printf "${FAILURE}\n" + echo "${WARNING} Falling back to current toolchain: $(rustc -V)" + + run_cargo test tarpc + run_cargo test tarpc_examples +fi RESULT=0 if [ "$TEST_RESULT" == "1" ]; From 34cf0c81724d9fcffc122b03b6ae9005839dfe83 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Mon, 15 Feb 2016 18:30:26 -0800 Subject: [PATCH 04/14] Updated hook to print messages like prepush --- hooks/pre-commit | 87 ++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 02d11c0..a72e35f 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -5,12 +5,25 @@ #!/bin/sh # -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. +# Pre-commit hook for the tarpc repository. To use this hook, copy it to .git/hooks in your +# repository root. # -# To enable this hook, rename this file to "pre-commit". +# Options: +# +# - TARPC_SKIP_RUSTFMT, default = 0 +# +# Set this to 1 to skip running rustfmt + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +PREFIX="${GREEN}[PRECOMMIT]${NC}" +FAILURE="${RED}FAILED${NC}" +WARNING="${RED}[WARNING]${NC}" +SKIPPED="${YELLOW}SKIPPED${NC}" +SUCCESS="${GREEN}ok${NC}" if git rev-parse --verify HEAD >/dev/null 2>&1 then @@ -20,43 +33,45 @@ else against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --bool hooks.allownonascii) - # Redirect output to stderr. exec 1>&2 -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | +FAILED=0 + +printf "${PREFIX} Checking that all filenames are ascii ... " +# Note that the use of brackets around a tr range is ok here, (it's +# even required, for portability to Solaris 10's /usr/bin/tr), since +# the square bracket bytes happen to fall in the designated range. +if test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. - -This can cause problems if you want to work with people on other platforms. - -To be portable it is advisable to rename the file. - -If you know what you are doing you can disable this check using: - - git config hooks.allownonascii true -EOF - exit 1 + FAILED=1 + printf "${FAILURE}\n" +else + printf "${SUCCESS}\n" fi -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- +printf "${PREFIX} Running rustfmt ... " +find tarpc/src -name "*.rs" -print0 | xargs -0 rustfmt --write-mode=overwrite &>/dev/null +FMTRESULT=$? +if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then + printf "${SKIPPED}\n" +elif [ ${FMTRESULT} != 0 ]; then + FAILED=1 + printf "${FAILURE}\n" +else + printf "${SUCCESS}\n" +fi -YELLOW='\033[0;33m' -NC='\033[0m' # No Color +printf "${PREFIX} Checking for bad whitespace ... " +git diff-index --check --cached $against -- &>/dev/null +if [ "$?" != 0 ]; then + FAILED=1 + printf "${FAILURE}\n" +else + printf "${SUCCESS}\n" +fi -function cargo_format() { - echo ${YELLOW}[PRECOMMIT]${NC} Formatting $1 ... - cargo fmt --manifest-path $1/Cargo.toml &>/dev/null -} +if [ ${FAILED} != 0 ]; then + exit 1 +fi From 07c052a1c1460dd302710d42484a993746a93faf Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Mon, 15 Feb 2016 18:54:15 -0800 Subject: [PATCH 05/14] Individually format crates, use -q --- hooks/pre-commit | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index a72e35f..76294cc 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -51,17 +51,22 @@ else printf "${SUCCESS}\n" fi -printf "${PREFIX} Running rustfmt ... " -find tarpc/src -name "*.rs" -print0 | xargs -0 rustfmt --write-mode=overwrite &>/dev/null -FMTRESULT=$? -if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then - printf "${SKIPPED}\n" -elif [ ${FMTRESULT} != 0 ]; then - FAILED=1 - printf "${FAILURE}\n" -else - printf "${SUCCESS}\n" -fi +function fmt() { + printf "${PREFIX} Running rustfmt on $1 ... " + (cd $1 && cargo-fmt -q) + FMTRESULT=$? + if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then + printf "${SKIPPED}\n" + elif [ ${FMTRESULT} != 0 ]; then + FAILED=1 + printf "${FAILURE}\n" + else + printf "${SUCCESS}\n" + fi +} + +fmt tarpc +fmt tarpc_examples printf "${PREFIX} Checking for bad whitespace ... " git diff-index --check --cached $against -- &>/dev/null From f2328d200e9a4bca8c83df9055dbd991678c76fc Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Mon, 15 Feb 2016 20:01:51 -0800 Subject: [PATCH 06/14] pre-commit doesn't modify files, just checks foramtting --- hooks/pre-commit | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 76294cc..7314a73 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -51,23 +51,6 @@ else printf "${SUCCESS}\n" fi -function fmt() { - printf "${PREFIX} Running rustfmt on $1 ... " - (cd $1 && cargo-fmt -q) - FMTRESULT=$? - if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then - printf "${SKIPPED}\n" - elif [ ${FMTRESULT} != 0 ]; then - FAILED=1 - printf "${FAILURE}\n" - else - printf "${SUCCESS}\n" - fi -} - -fmt tarpc -fmt tarpc_examples - printf "${PREFIX} Checking for bad whitespace ... " git diff-index --check --cached $against -- &>/dev/null if [ "$?" != 0 ]; then @@ -77,6 +60,28 @@ else printf "${SUCCESS}\n" fi +printf "${PREFIX} Checking formatting ... " +FMTRESULT=0 +for file in $(git diff --name-only --cached); +do + if [ ${file: -3} == ".rs" ]; then + HASH=$(shasum $file) + NEW_HASH=$(rustfmt --write-mode=display $file | shasum) + if [ "${HASH}" != "${NEW_HASH}" ]; then + FMTRESULT=1 + fi + fi +done + +if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then + printf "${SKIPPED}\n"$? +elif [ ${FMTRESULT} != 0 ]; then + FAILED=1 + printf "${FAILURE}\n" +else + printf "${SUCCESS}\n" +fi + if [ ${FAILED} != 0 ]; then exit 1 fi From 403eba201b6b4bbc57cc4451e515914f1d610ded Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Mon, 15 Feb 2016 20:05:09 -0800 Subject: [PATCH 07/14] Group builds/tests by toolchain for speed --- hooks/pre-push | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/pre-push b/hooks/pre-push index c76c0fb..3bd6132 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -89,9 +89,9 @@ then # No need to build on nightly, the tests will do that run_cargo build tarpc stable - run_cargo build tarpc beta - run_cargo build tarpc_examples stable + + run_cargo build tarpc beta run_cargo build tarpc_examples beta # We still rely on some nightly stuff for tests From 17d800b8a814595c1dd184fd345a887d799f4069 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Mon, 15 Feb 2016 20:12:37 -0800 Subject: [PATCH 08/14] Update comments --- hooks/pre-commit | 3 +++ hooks/pre-push | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 7314a73..5597d32 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -13,6 +13,9 @@ # - TARPC_SKIP_RUSTFMT, default = 0 # # Set this to 1 to skip running rustfmt +# +# Note that these options are most useful for testing the hooks themselves. Use git commit +# --no-verify to skip the pre-commit hook altogether. RED='\033[0;31m' GREEN='\033[0;32m' diff --git a/hooks/pre-push b/hooks/pre-push index 3bd6132..707b4ea 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -10,7 +10,7 @@ # to build and test the code on the appropriate toolchains. The working copy must not contain # uncommitted changes, since the script currently just runs cargo build/test in the working copy. # -# There are a few options that can be set by setting environment variables. +# Options: # # - TARPC_ALLOW_DIRTY, default = 0 # @@ -22,6 +22,9 @@ # # Setting this variable to 1 will just run cargo build and cargo test, rather than running # stable/beta/nightly. +# +# Note that these options are most useful for testing the hooks themselves. Use git push --no-verify +# to skip the pre-push hook altogether. #!/bin/sh From 3462451256f8ccb3e8451128ea1deff6591184ce Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Wed, 17 Feb 2016 18:18:22 -0800 Subject: [PATCH 09/14] Check for multirust, rustfmt, clean up some things --- hooks/pre-commit | 18 ++++++++++++++++++ hooks/pre-push | 48 +++++++++++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 5597d32..e895800 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -8,6 +8,12 @@ # Pre-commit hook for the tarpc repository. To use this hook, copy it to .git/hooks in your # repository root. # +# This precommit checks the following: +# 1. All filenames are ascii +# 2. There is no bad whitespace +# 3. rustfmt is installed +# 4. rustfmt is a noop on files that are in the index +# # Options: # # - TARPC_SKIP_RUSTFMT, default = 0 @@ -63,6 +69,18 @@ else printf "${SUCCESS}\n" fi +printf "${PREFIX} Checking for rustfmt ... " +command -v rustfmt &>/dev/null +if [ $? == 0 ]; then + printf "${SUCCESS}\n" +else + printf "${FAILURE}\n" + exit 1 +fi + +# Just check that running rustfmt doesn't do anything to the file. I do this instead of +# modifying the file because I don't want to mess with the developer's index, which may +# not only contain discrete files. printf "${PREFIX} Checking formatting ... " FMTRESULT=0 for file in $(git diff --name-only --cached); diff --git a/hooks/pre-push b/hooks/pre-push index 707b4ea..193a7a3 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -40,56 +40,68 @@ SUCCESS="${GREEN}ok${NC}" printf "${PREFIX} Clean working copy ... " git diff --exit-code &>/dev/null -if [ "$?" == 0 ]; -then +if [ "$?" == 0 ]; then printf "${SUCCESS}\n" else printf "${FAILURE}\n" if [ "${TARPC_ALLOW_DIRTY}" == "1" ] then - echo ${WARNING} Running with unclean working directory + printf "${WARNING} Running with unclean working directory\n" else exit 1 fi fi -TEST_RESULT=0 +PREPUSH_RESULT=0 # args: # 1 - cargo command to run (build/test) # 2 - directory name of crate to build # 3 - rust toolchain (nightly/stable/beta) function run_cargo() { - if [ "$1" == "build" ] - then + if [ "$1" == "build" ]; then VERB=Building else VERB=Testing fi - if [ "$3" != "" ] - then + if [ "$3" != "" ]; then printf "${PREFIX} $VERB $2 on $3 ... " multirust run $3 cargo $1 --manifest-path $2/Cargo.toml &>/dev/null else printf "${PREFIX} $VERB $2 ... " cargo $1 --manifest-path $2/Cargo.toml &>/dev/null fi - if [ "$?" != "0" ]; - then + if [ "$?" != "0" ]; then printf "${FAILURE}\n" - #printf "${OUTPUT}\n" - TEST_RESULT=1 + PREPUSH_RESULT=1 else printf "${SUCCESS}\n" fi } +TOOLCHAIN_RESULT=0 +check_toolchain() { + printf "${PREFIX} Checking for $1 toolchain ... " + if [[ $(multirust list-toolchain) =~ $1 ]]; then + printf "${SUCCESS}\n" + else + TOOLCHAIN_RESULT=1 + PREPUSH_RESULT=1 + printf "${FAILURE}\n" + fi + PREPUSH_RESULT=1 +} + printf "${PREFIX} Checking for multirust ... " command -v multirust &>/dev/null -if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; -then +if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; then printf "${SUCCESS}\n" + check_toolchain stable + check_toolchain beta + check_toolchain nightly + [ ${TOOLCHAIN_RESULT} ] && exit 1 + # No need to build on nightly, the tests will do that run_cargo build tarpc stable run_cargo build tarpc_examples stable @@ -108,10 +120,4 @@ else run_cargo test tarpc_examples fi -RESULT=0 -if [ "$TEST_RESULT" == "1" ]; -then - RESULT=1 -fi - -exit $RESULT +exit $PREPUSH_RESULT From 82762583be50c4e2c08f452c290b6a142549f01b Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Wed, 17 Feb 2016 18:36:48 -0800 Subject: [PATCH 10/14] Change colors a bit, only exit when check_toolchain fails.. --- hooks/pre-push | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hooks/pre-push b/hooks/pre-push index 193a7a3..491a65d 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -35,7 +35,8 @@ NC='\033[0m' # No Color PREFIX="${GREEN}[PREPUSH]${NC}" FAILURE="${RED}FAILED${NC}" -WARNING="${RED}[WARNING]${NC}" +WARNING="${YELLOW}[WARNING]${NC}" +SKIPPED="${YELLOW}SKIPPED${NC}" SUCCESS="${GREEN}ok${NC}" printf "${PREFIX} Clean working copy ... " @@ -43,11 +44,11 @@ git diff --exit-code &>/dev/null if [ "$?" == 0 ]; then printf "${SUCCESS}\n" else - printf "${FAILURE}\n" if [ "${TARPC_ALLOW_DIRTY}" == "1" ] then - printf "${WARNING} Running with unclean working directory\n" + printf "${SKIPPED}\n" else + printf "${FAILURE}\n" exit 1 fi fi @@ -89,7 +90,6 @@ check_toolchain() { PREPUSH_RESULT=1 printf "${FAILURE}\n" fi - PREPUSH_RESULT=1 } printf "${PREFIX} Checking for multirust ... " @@ -100,7 +100,9 @@ if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; then check_toolchain stable check_toolchain beta check_toolchain nightly - [ ${TOOLCHAIN_RESULT} ] && exit 1 + if [ ${TOOLCHAIN_RESULT} == 1 ]; then + exit 1 + fi # No need to build on nightly, the tests will do that run_cargo build tarpc stable @@ -114,7 +116,7 @@ if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; then run_cargo test tarpc_examples nightly else printf "${FAILURE}\n" - echo "${WARNING} Falling back to current toolchain: $(rustc -V)" + printf "${WARNING} Falling back to current toolchain: $(rustc -V)\n" run_cargo test tarpc run_cargo test tarpc_examples From a06b583334058f2e254ae85de6bdc581c122267f Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Thu, 18 Feb 2016 01:27:07 -0800 Subject: [PATCH 11/14] Also check existence of shasum --- hooks/pre-commit | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index e895800..ae144b9 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -78,6 +78,15 @@ else exit 1 fi +printf "${PREFIX} Checking for shasum ... " +command -v shasum &>/dev/null +if [ $? == 0 ]; then + printf "${SUCCESS}\n" +else + printf "${FAILURE}\n" + exit 1 +fi + # Just check that running rustfmt doesn't do anything to the file. I do this instead of # modifying the file because I don't want to mess with the developer's index, which may # not only contain discrete files. @@ -103,6 +112,4 @@ else printf "${SUCCESS}\n" fi -if [ ${FAILED} != 0 ]; then - exit 1 -fi +exit ${FAILED} From 6d23174219b7d6c722686d2610ebea27981e81fc Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Thu, 18 Feb 2016 01:36:39 -0800 Subject: [PATCH 12/14] Build on nightly too, as per review comment --- hooks/pre-push | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hooks/pre-push b/hooks/pre-push index 491a65d..bd5474b 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -104,13 +104,15 @@ if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; then exit 1 fi - # No need to build on nightly, the tests will do that run_cargo build tarpc stable run_cargo build tarpc_examples stable run_cargo build tarpc beta run_cargo build tarpc_examples beta + run_cargo build tarpc nightly + run_cargo build tarpc_examples nightly + # We still rely on some nightly stuff for tests run_cargo test tarpc nightly run_cargo test tarpc_examples nightly From d0e96932634548f2f1fba8ec04d37987e5a98597 Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Thu, 18 Feb 2016 01:40:44 -0800 Subject: [PATCH 13/14] Be consistent with function declarations --- hooks/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/pre-push b/hooks/pre-push index bd5474b..68f26c7 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -59,7 +59,7 @@ PREPUSH_RESULT=0 # 1 - cargo command to run (build/test) # 2 - directory name of crate to build # 3 - rust toolchain (nightly/stable/beta) -function run_cargo() { +run_cargo() { if [ "$1" == "build" ]; then VERB=Building else From 4ed127b39ee6dd5463aab15c2829abd0d34e2aaf Mon Sep 17 00:00:00 2001 From: Adam Wright Date: Fri, 19 Feb 2016 21:31:11 -0800 Subject: [PATCH 14/14] NOT FOUND instead of FAILED --- hooks/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/pre-push b/hooks/pre-push index 68f26c7..a488ea8 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -117,7 +117,7 @@ if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; then run_cargo test tarpc nightly run_cargo test tarpc_examples nightly else - printf "${FAILURE}\n" + printf "${YELLOW}NOT FOUND${NC}\n" printf "${WARNING} Falling back to current toolchain: $(rustc -V)\n" run_cargo test tarpc