diff options
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/check_commit.sh | 30 | ||||
| -rwxr-xr-x | tools/checkpatch.sh | 72 | ||||
| -rwxr-xr-x | tools/cpep8.py | 2 |
3 files changed, 22 insertions, 82 deletions
diff --git a/tools/check_commit.sh b/tools/check_commit.sh index 9273912..5b8887c 100755 --- a/tools/check_commit.sh +++ b/tools/check_commit.sh @@ -17,28 +17,29 @@ git log --pretty=oneline --no-merges --abbrev-commit ${BASE}.. echo git diff ${BASE}.. -- '*.py' | grep '^+' > added_lines +git diff ${BASE}.. -- 'chirp/drivers/*.py' | grep '^+' > driver_lines -if grep -E '(from|import).*six' added_lines; then - fail No new uses of future +if grep -E '\<(from|import)\>.*\<six\>' added_lines; then + fail No new uses of six fi -if grep -E '\wsix\w' added_lines; then +if grep -E '\<six\>' added_lines; then fail No new uses of six fi -if grep -E '(from|import).*builtins' added_lines; then +if grep -E '\<(from|import)\>.*builtins' added_lines; then fail No new uses of future fi -if grep -E '\wfuture\w' added_lines; then +if grep -E '\<future\>' added_lines; then fail No new uses of future fi -if grep -E '(from|import).*past(?!e)' added_lines; then +if grep -E '\<(from|import)\>.*\<past\>' added_lines; then fail Use of past library not allowed fi -if grep -E 'MemoryMap\(' added_lines; then +if grep -E '\<MemoryMap\(' added_lines; then fail New uses of MemoryMap should be MemoryMapBytes fi @@ -46,7 +47,7 @@ if grep -E "[^_]_\([^\"']" added_lines; then fail 'Translated strings must be literals!' fi -if grep -E "eval\(" added_lines; then +if grep -E "\<eval\(" added_lines; then fail 'Use of eval() is dangerous and not permitted!' fi @@ -73,15 +74,26 @@ done # fail 'New drivers should not have match_model() implemented as it is not needed' #fi -if grep -E '\Wprint\(' added_lines; then +if grep -E '\<print\(' added_lines; then fail 'Do not use print()' fi +if grep -E '\<(from|import)\>.*wx' driver_lines; then + fail 'Drivers may not import GUI components or manipulate the GUI' +fi + +if grep -E '(subprocess|webbrowser)' driver_lines; then + fail 'Drivers may not spawn external commands' +fi + if git log ${BASE}.. --merges | grep .; then fail Please do not include merge commits in your PR fi make -C chirp/locale clean all >/dev/null 2>&1 +if [ $? -ne 0 ]; then + fail Locale build failed +fi if git diff -- chirp/locale | grep '^+[^#+]' | grep -v POT-Creation; then fail Locale files need updating fi diff --git a/tools/checkpatch.sh b/tools/checkpatch.sh deleted file mode 100755 index 5cf3a6f..0000000 --- a/tools/checkpatch.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env bash -# -# CHIRP coding standards compliance script -# -# To add a test to this file, create a new check_foo() function -# and then add it to the list of TESTS= below -# - -TESTS="check_long_lines check_bug_number check_commit_message_line_length" - -function check_long_lines() { - local rev="$1" - local files="$2" - - # For now, ignore this check on chirp/ - files=$(echo $files | sed -r 's#\bchirp[^ ]*\b##') - - if [ -z "$files" ]; then - return - fi - - pep8 --select=E501 $files || \ - error "Please use <80 columns in source files" -} - -function check_bug_number() { - local rev="$1" - hg log -vr $rev | grep -qE '#[0-9]+' || \ - error "A bug number is required like #123" -} - -function _less_than_80() { - while true; do - read line - if [ -z "$line" ]; then - break - elif [ $(echo -n "$line" | wc -c) -ge 80 ]; then - return 1 - fi - done -} - -function check_commit_message_line_length() { - local rev="$1" - hg log -vr $rev | (_less_than_80) || \ - error "Please keep commit message lines to <80 columns" -} - -# --- END OF TEST FUNCTIONS --- - -function error() { - echo FAIL: $* - ERROR=1 -} - -function get_touched_files() { - local rev="$1" - hg status -n --change $rev | grep '\.py$' -} - -rev=${1:-tip} -files=$(get_touched_files $rev) - -for testname in $TESTS; do - eval "$testname $rev \"$files\"" -done - -if [ -z "$ERROR" ]; then - echo "Patch '${rev}' is OK" -else - exit 1 -fi diff --git a/tools/cpep8.py b/tools/cpep8.py index a1fde83..60db7c3 100755 --- a/tools/cpep8.py +++ b/tools/cpep8.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # cpep8.py - Check Python source files for PEP8 compliance. # |
