Add tolerant mode to Signed-off-by check (#1322)

In tolerant mode, only the existence of the Signed-off-by line is
checked but the name and address is not matched against the author
of the commit.

The tools/run-tests.py script is extended to allow calling the
check script in tolerant mode and also to detect whether it is
being run by Travis CI.

The Travis CI config has been modified to check PRs in strict mode
but use tolerant mode for merges to master. This should enable the
use of the Merge button on the GitHub web interface. (The PR is
strictly checked when a contributor opens it but when a committer
merges it via the web interface and GitHub rewrites author details
from the contributor's profile, master will not turn red either.)

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2016-09-07 12:28:29 +02:00
committed by Tilmann Scheller
parent 714e8d261b
commit 8d478c142b
3 changed files with 72 additions and 8 deletions
+1 -1
View File
@@ -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
+60 -6
View File
@@ -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
+11 -1
View File
@@ -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):