1# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
2# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
3# Copyright 2014 Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
4# Copyright 2020 Jonathan Demeyer <jona.dem@gmail.com>
5#
6# This file is subject to the terms and conditions of the GNU Lesser
7# General Public License v2.1. See the file LICENSE in the top level
8# directory for more details.
9
10changed_files() {
11    : ${FILEREGEX:='\.([CcHh])$'}
12    : ${EXCLUDE:=''}
13    : ${DIFFFILTER:='ACMR'}
14
15    DIFFFILTER="--diff-filter=${DIFFFILTER}"
16
17    # select either all or only touched-in-branch files, filter through FILEREGEX
18    if [ -z "${BASE_BRANCH}" ]; then
19        FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
20    else
21        FILES="$(git diff ${DIFFFILTER} --name-only ${BASE_BRANCH} | grep -E ${FILEREGEX})"
22    fi
23
24    # filter out negatives
25    echo "${FILES}" | grep -v -E ${EXCLUDE}
26}
27