mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-22 00:31:07 -05:00
Use git check-ignore instead of a (incomplete) list of ignored files
The list-based method breaks down in case of ignored folders: If .gitignore contains foo/, foo/bar.py is still checked. Signed-off-by: Christoph Höger <christoph.hoeger@piano.io>
This commit is contained in:
parent
d0002cc016
commit
adbf28f42d
1 changed files with 1 additions and 21 deletions
|
@ -228,26 +228,6 @@ function BuildFileList() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
###############################
|
|
||||||
# Load the ignored files list #
|
|
||||||
###############################
|
|
||||||
debug "Loading the files list that Git ignores..."
|
|
||||||
mapfile -t GIT_IGNORED_FILES < <(git -C "${GITHUB_WORKSPACE}" status --ignored --porcelain=v1 --short --untracked-files=normal | grep '!!' | awk -F ' ' '{print $2}' | sed -e 's#^#'"${GITHUB_WORKSPACE}"/'#' | sort)
|
|
||||||
debug "GIT_IGNORED_FILES contents: ${GIT_IGNORED_FILES[*]}"
|
|
||||||
|
|
||||||
# Build an associative array to avoid looping throug the ignored files list
|
|
||||||
local i
|
|
||||||
declare -g -A GIT_IGNORED_FILES_INDEX
|
|
||||||
for i in "${!GIT_IGNORED_FILES[@]}"; do
|
|
||||||
eval GIT_IGNORED_FILES_INDEX["${GIT_IGNORED_FILES[$i]}"]="$i"
|
|
||||||
done
|
|
||||||
debug "--- GIT_IGNORED_FILES_INDEX contents ---"
|
|
||||||
debug "-----------------------"
|
|
||||||
for i in "${!GIT_IGNORED_FILES_INDEX[@]}"; do
|
|
||||||
debug "key: $i, value: ${GIT_IGNORED_FILES_INDEX[$i]}"
|
|
||||||
done
|
|
||||||
debug "---------------------------------------------"
|
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Check if the Ansible directory exists #
|
# Check if the Ansible directory exists #
|
||||||
#########################################
|
#########################################
|
||||||
|
@ -316,7 +296,7 @@ function BuildFileList() {
|
||||||
###################################################
|
###################################################
|
||||||
# Filter files if FILTER_REGEX_EXCLUDE is not set #
|
# Filter files if FILTER_REGEX_EXCLUDE is not set #
|
||||||
###################################################
|
###################################################
|
||||||
if [ "${GIT_IGNORED_FILES_INDEX[$FILE]}" ] && [ "${IGNORE_GITIGNORED_FILES}" == "true" ]; then
|
if git check-ignore "$FILE" && [ "${IGNORE_GITIGNORED_FILES}" == "true" ]; then
|
||||||
debug "${FILE} is ignored by Git. Skipping ${FILE}"
|
debug "${FILE} is ignored by Git. Skipping ${FILE}"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue