diff --git a/.travis.yml b/.travis.yml index 309abfc0e..79312c970 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ install: script: "python tools/run-tests.py $OPTS" env: - - OPTS="--check-signed-off --check-cppcheck --check-vera" + - OPTS="--check-signed-off-travis --check-cppcheck --check-vera" - OPTS="--jerry-tests --jerry-test-suite" - OPTS="--jerry-tests --jerry-test-suite --toolchain=cmake/toolchain_linux_armv7l.cmake" TIMEOUT=300 - OPTS=--buildoption-test diff --git a/tools/check-signed-off.sh b/tools/check-signed-off.sh index 038c1ff7a..21b2f1ca8 100755 --- a/tools/check-signed-off.sh +++ b/tools/check-signed-off.sh @@ -15,6 +15,49 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Usage +function print_usage +{ + echo "Usage: $0 [--help] [--tolerant]" +} + +function print_help +{ + echo "$0: Check Signed-off-by message of the latest commit" + echo "" + print_usage + echo "" + echo "Optional arguments:" + echo " --help print this help message" + echo " --tolerant check the existence of the message only but don't" + echo " require the name and email address to match the author" + echo " of the commit" + echo "" + echo "The last line of every commit message must follow the form of:" + echo "'JerryScript-DCO-1.0-Signed-off-by: NAME EMAIL', where NAME and EMAIL must" + echo "match the name and email address of the author of the commit (unless in" + echo "tolerant mode)." +} + +# Processing command line +TOLERANT="no" +while [ "$#" -gt 0 ] +do + if [ "$1" == "--help" ] + then + print_help + exit 0 + elif [ "$1" == "--tolerant" ] + then + TOLERANT="yes" + shift + else + print_usage + exit 1 + fi +done + +# Determining latest commit parent_hashes=(`git show -s --format=%p HEAD | head -1`) if [ "${#parent_hashes[@]}" -eq 1 ] @@ -28,16 +71,27 @@ else exit 1 fi -author_name=`git show -s --format=%an $commit_hash` -author_email=`git show -s --format=%ae $commit_hash` -required_signed_off_by_line="JerryScript-DCO-1.0-Signed-off-by: $author_name $author_email" +# Checking the last line actual_signed_off_by_line=`git show -s --format=%B $commit_hash | sed '/^$/d' | tr -d '\015' | tail -n 1` -if [ "$actual_signed_off_by_line" != "$required_signed_off_by_line" ] +if [ "$TOLERANT" == "no" ] then - echo -e "\e[1;33mSigned-off-by message is incorrect. The following line should be at the end of the $commit_hash commit's message: '$required_signed_off_by_line'. \e[0m" + author_name=`git show -s --format=%an $commit_hash` + author_email=`git show -s --format=%ae $commit_hash` + required_signed_off_by_line="JerryScript-DCO-1.0-Signed-off-by: $author_name $author_email" - exit 1 + if [ "$actual_signed_off_by_line" != "$required_signed_off_by_line" ] + then + echo -e "\e[1;33mSigned-off-by message is incorrect. The following line should be at the end of the $commit_hash commit's message: '$required_signed_off_by_line'. \e[0m" + exit 1 + fi +else + echo -e "\e[1;33mWarning! The name and email address of the author of the $commit_hash commit is not checked in tolerant mode! \e[0m" + if echo "$actual_signed_off_by_line" | grep -q -v '^JerryScript-DCO-1.0-Signed-off-by:' + then + echo -e "\e[1;33mSigned-off-by message is incorrect. The following line should be at the end of the $commit_hash commit's message: '$required_signed_off_by_line'. \e[0m" + exit 1 + fi fi exit 0 diff --git a/tools/run-tests.py b/tools/run-tests.py index e4a2904b9..946e531b2 100755 --- a/tools/run-tests.py +++ b/tools/run-tests.py @@ -16,6 +16,7 @@ # limitations under the License. import argparse +import os import subprocess import sys from settings import * @@ -26,6 +27,8 @@ parser = argparse.ArgumentParser() parser.add_argument('--toolchain', action='store', default='', help='Add toolchain file') parser.add_argument('--outdir', action='store', default=OUTPUT_DIR, help='Specify output directory (default: %(default)s)') parser.add_argument('--check-signed-off', action='store_true', default=False, help='Run signed-off check') +parser.add_argument('--check-signed-off-tolerant', action='store_true', default=False, help='Run signed-off check in tolerant mode') +parser.add_argument('--check-signed-off-travis', action='store_true', default=False, help='Run signed-off check in tolerant mode if on Travis CI and not checking a pull request') parser.add_argument('--check-cppcheck', action='store_true', default=False, help='Run cppcheck') parser.add_argument('--check-vera', action='store_true', default=False, help='Run vera check') parser.add_argument('--buildoption-test', action='store_true', default=False, help='Run buildoption-test') @@ -180,7 +183,14 @@ def run_buildoption_test(): def main(): ret = 0 - if script_args.all or script_args.check_signed_off: + if script_args.check_signed_off_tolerant: + ret = run_check([SIGNED_OFF_SCRIPT, '--tolerant']) + + if not ret and script_args.check_signed_off_travis: + runnable = SIGNED_OFF_SCRIPT if os.getenv('TRAVIS_PULL_REQUEST', '0') != 'false' else [SIGNED_OFF_SCRIPT, '--tolerant'] + ret = run_check(runnable) + + if not ret and (script_args.all or script_args.check_signed_off): ret = run_check(SIGNED_OFF_SCRIPT) if not ret and (script_args.all or script_args.check_cppcheck):