dist/tools/licenses/check.sh: make use of changed_files.sh
This commit is contained in:
parent
e24becc02a
commit
a02472d1fa
40
dist/tools/licenses/check.sh
vendored
40
dist/tools/licenses/check.sh
vendored
@ -1,11 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
||||||
#
|
#
|
||||||
# This file is subject to the terms and conditions of the GNU Lesser
|
# This file is subject to the terms and conditions of the GNU Lesser
|
||||||
# General Public License v2.1. See the file LICENSE in the top level
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
# directory for more details.
|
# directory for more details.
|
||||||
|
|
||||||
|
. ${RIOTBASE:+${RIOTBASE}/}dist/tools/ci/changed_files.sh
|
||||||
|
|
||||||
# customizable
|
# customizable
|
||||||
CHECKROOT=$(dirname "${0}")
|
CHECKROOT=$(dirname "${0}")
|
||||||
LICENSEDIR="${CHECKROOT}/patterns"
|
LICENSEDIR="${CHECKROOT}/patterns"
|
||||||
@ -20,7 +23,8 @@ TAB_CHAR="$(printf '\t')"
|
|||||||
ROOT=$(git rev-parse --show-toplevel)
|
ROOT=$(git rev-parse --show-toplevel)
|
||||||
LICENSES=$(ls "${LICENSEDIR}")
|
LICENSES=$(ls "${LICENSEDIR}")
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
ERROR_EXIT_CODE="1"
|
|
||||||
|
: ${ERROR_EXIT_CODE:=1}
|
||||||
|
|
||||||
# reset output dir
|
# reset output dir
|
||||||
rm -fr "${OUTPUT}"
|
rm -fr "${OUTPUT}"
|
||||||
@ -29,39 +33,7 @@ for LICENSE in ${LICENSES}; do
|
|||||||
echo -n '' > "${OUTPUT}/${LICENSE}"
|
echo -n '' > "${OUTPUT}/${LICENSE}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# If no branch but an option is given, unset BRANCH.
|
FILES=$(FILEREGEX='\.([sSch]|cpp)$' changed_files)
|
||||||
# Otherwise, consume this parameter.
|
|
||||||
BRANCH="${1}"
|
|
||||||
if echo "${BRANCH}" | grep -q '^-'; then
|
|
||||||
BRANCH=""
|
|
||||||
else
|
|
||||||
if [ -n "${BRANCH}" ]; then
|
|
||||||
shift 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the --diff-filter option is given, consume this parameter.
|
|
||||||
# Set the default DIFFFILTER option otherwise.
|
|
||||||
DIFFFILTER="${1}"
|
|
||||||
if echo "${DIFFFILTER}" | grep -q '^--diff-filter='; then
|
|
||||||
shift 1
|
|
||||||
else
|
|
||||||
DIFFFILTER="--diff-filter=ACMR"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# If the --error-exitcode option is given, consume this parameter
|
|
||||||
# and overwrite the default ERROR_EXIT_CODE.
|
|
||||||
if echo "${1}" | grep -q '^--error-exitcode='; then
|
|
||||||
ERROR_EXIT_CODE=$(echo ${1} | sed -e 's/--error-exitcode=//')
|
|
||||||
shift 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# select files to check
|
|
||||||
if [ -z "${BRANCH}" ]; then
|
|
||||||
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E '\.([sSch]|cpp)$')"
|
|
||||||
else
|
|
||||||
FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E '\.([sSchp]|cpp)$')"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# categorize files
|
# categorize files
|
||||||
for FILE in ${FILES}; do
|
for FILE in ${FILES}; do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user