Allow ansible-lint with git diffs (#1554)

* Allow ansible-lint with git diffs

super-linter checks the path of the file in lib/functions/detectFiles.sh to determine whether the file is an ansible playbook. When VALIDATE_ALL_CODEBASE=true, a list of absolute paths is generated which matches the expected path but when VALIDATE_ALL_CODEBASE=false, a list of relative paths is generated so no files are "detected" as ansible playbooks. This change outputs everything as an absolute path so diffs will also work.

* fix quotes

* Include eval to interpret pipe in cmd substitution

* more quotes

Co-authored-by: Admiral Awkbar <admiralawkbar@github.com>
This commit is contained in:
DanEmord 2021-05-12 07:59:31 -07:00 committed by GitHub
parent 5a91fddf5d
commit 3dc85fc3bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,7 +20,7 @@ function GenerateFileDiff() {
################################################# #################################################
# Get the Array of files changed in the commits # # Get the Array of files changed in the commits #
################################################# #################################################
CMD_OUTPUT=$($CMD) CMD_OUTPUT=$(eval "$CMD")
####################### #######################
# Load the error code # # Load the error code #
@ -100,7 +100,7 @@ function BuildFileList() {
################ ################
# push event # # push event #
################ ################
DIFF_TREE_CMD="git -C ${GITHUB_WORKSPACE} diff-tree --no-commit-id --name-only -r ${GITHUB_SHA}" DIFF_TREE_CMD="git -C ${GITHUB_WORKSPACE} diff-tree --no-commit-id --name-only -r ${GITHUB_SHA} | xargs -I % sh -c 'echo \"${GITHUB_WORKSPACE}/%\"' 2>&1"
GenerateFileDiff "$DIFF_TREE_CMD" GenerateFileDiff "$DIFF_TREE_CMD"
############################################################### ###############################################################
@ -114,7 +114,7 @@ function BuildFileList() {
debug "----------------------------------------------" debug "----------------------------------------------"
debug "WARN: Generation of File array with diff-tree produced [0] items, trying with git diff..." debug "WARN: Generation of File array with diff-tree produced [0] items, trying with git diff..."
DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d" DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d | xargs -I % sh -c 'echo \"${GITHUB_WORKSPACE}/%\"' 2>&1"
GenerateFileDiff "$DIFF_CMD" GenerateFileDiff "$DIFF_CMD"
fi fi
@ -122,7 +122,7 @@ function BuildFileList() {
################ ################
# PR event # # PR event #
################ ################
DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d" DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d | xargs -I % sh -c 'echo \"${GITHUB_WORKSPACE}/%\"' 2>&1"
GenerateFileDiff "$DIFF_CMD" GenerateFileDiff "$DIFF_CMD"
fi fi
else else