From 3dc85fc3bc1f47c6cf14831c666f569b153e9fb9 Mon Sep 17 00:00:00 2001 From: DanEmord Date: Wed, 12 May 2021 07:59:31 -0700 Subject: [PATCH] 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 --- lib/functions/buildFileList.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/functions/buildFileList.sh b/lib/functions/buildFileList.sh index 165cc263..e518ee88 100755 --- a/lib/functions/buildFileList.sh +++ b/lib/functions/buildFileList.sh @@ -20,7 +20,7 @@ function GenerateFileDiff() { ################################################# # Get the Array of files changed in the commits # ################################################# - CMD_OUTPUT=$($CMD) + CMD_OUTPUT=$(eval "$CMD") ####################### # Load the error code # @@ -100,7 +100,7 @@ function BuildFileList() { ################ # 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" ############################################################### @@ -114,7 +114,7 @@ function BuildFileList() { debug "----------------------------------------------" 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" fi @@ -122,7 +122,7 @@ function BuildFileList() { ################ # 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" fi else