Skip to content

Commit 7544dbc

Browse files
committed
Honour the paths-ignore (but not paths) config var
1 parent e4086d2 commit 7544dbc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

extractors/cds/tools/index-files.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,25 @@ if [ -z "${CODEQL_EXTRACTOR_JAVASCRIPT_ROOT:-}" ]; then
7373
export CODEQL_EXTRACTOR_JAVASCRIPT_SOURCE_ARCHIVE_DIR="$CODEQL_EXTRACTOR_CDS_SOURCE_ARCHIVE_DIR"
7474
fi
7575

76+
# Check if LGTM_INDEX_FILTERS is already set
77+
# This typically happens if "paths" or "paths-ignore" are set in the LGTM.yml file
78+
if [ -z "${LGTM_INDEX_FILTERS:-}" ]; then
79+
# If it is set, we will try to honour the paths-ignore filter
80+
# Split by \n and find all the entries that start with exclude, excluding "exclude:**/*" and "exclude:**/*.*"
81+
# and then join them back together with \n
82+
exclude_filters="\n$(grep '^exclude' "$LGTM_INDEX_FILTERS" | grep -v 'exclude:**/\*\|exclude:**/\*\.\*')"
83+
else
84+
exclude_filters=""
85+
fi
86+
7687
# Enable extraction of the cds.json files only
77-
export LGTM_INDEX_FILTERS=$'exclude:**/*.*\ninclude:**/*.cds.json\ninclude:**/*.cds\nexclude:**/node_modules/**/*.*'
88+
export LGTM_INDEX_FILTERS=$'exclude:**/*.*\ninclude:**/*.cds.json\ninclude:**/*.cds\nexclude:**/node_modules/**/*.*'"$exclude_filters"
7889
export LGTM_INDEX_TYPESCRIPT="NONE"
7990
# Configure to copy over the CDS files as well, by pretending they are JSON
8091
export LGTM_INDEX_FILETYPES=".cds:JSON"
92+
# Ignore the LGTM_INDEX_INCLUDE variable for this purpose, as it may
93+
# refer explicitly to .ts or .js files
94+
unset LGTM_INDEX_INCLUDE
8195

8296
echo "Extracting the cds.json files"
8397

0 commit comments

Comments
 (0)