diff --git a/dist/tools/ci/changed_files.sh b/dist/tools/ci/changed_files.sh new file mode 100644 index 000000000..fd42941f5 --- /dev/null +++ b/dist/tools/ci/changed_files.sh @@ -0,0 +1,25 @@ +# Copyright 2017 Kaspar Schleiser +# Copyright 2014 Ludwig Knüpfer +# Copyright 2014 Hinnerk van Bruinehsen +# +# 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 +# directory for more details. + +changed_files() { + : ${FILEREGEX:='\.([CcHh]|[ch]pp)$'} + : ${EXCLUDE:='^(.+/include/vendor/)'} + : ${DIFFFILTER:='ACMR'} + + DIFFFILTER="--diff-filter=${DIFFFILTER}" + + # select either all or only touched-in-branch files, filter through FILEREGEX + if [ -z "${BASE_BRANCH}" ]; then + FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})" + else + FILES="$(git diff ${DIFFFILTER} --name-only ${BASE_BRANCH} | grep -E ${FILEREGEX})" + fi + + # filter out negatives + echo "${FILES}" | grep -v -E ${EXCLUDE} +}