Skip to content

Commit 3dc85fc

Browse files
Allow ansible-lint with git diffs (super-linter#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>
1 parent 5a91fdd commit 3dc85fc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/functions/buildFileList.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function GenerateFileDiff() {
2020
#################################################
2121
# Get the Array of files changed in the commits #
2222
#################################################
23-
CMD_OUTPUT=$($CMD)
23+
CMD_OUTPUT=$(eval "$CMD")
2424

2525
#######################
2626
# Load the error code #
@@ -100,7 +100,7 @@ function BuildFileList() {
100100
################
101101
# push event #
102102
################
103-
DIFF_TREE_CMD="git -C ${GITHUB_WORKSPACE} diff-tree --no-commit-id --name-only -r ${GITHUB_SHA}"
103+
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"
104104
GenerateFileDiff "$DIFF_TREE_CMD"
105105

106106
###############################################################
@@ -114,15 +114,15 @@ function BuildFileList() {
114114
debug "----------------------------------------------"
115115
debug "WARN: Generation of File array with diff-tree produced [0] items, trying with git diff..."
116116

117-
DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d"
117+
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"
118118
GenerateFileDiff "$DIFF_CMD"
119119

120120
fi
121121
else
122122
################
123123
# PR event #
124124
################
125-
DIFF_CMD="git -C ${GITHUB_WORKSPACE} diff --name-only ${DEFAULT_BRANCH}...${GITHUB_SHA} --diff-filter=d"
125+
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"
126126
GenerateFileDiff "$DIFF_CMD"
127127
fi
128128
else

0 commit comments

Comments
 (0)