Skip to content

tests: use correct HEAD to list files #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tests/patch/pylint/pylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pr() {
echo " ====== $@ ======" | tee -a /dev/stderr
}

# If it doesn't touch .py files, don't bother. Ignore created and deleted.
if ! git show --diff-filter=AM --pretty="" --name-only HEAD | grep -q -E "\.py$"
# If it doesn't touch .py files, don't bother. Ignore deleted.
if ! git show --diff-filter=AM --pretty="" --name-only "${HEAD}" | grep -q -E "\.py$"
then
echo "No python scripts touched, skip" >&$DESC_FD
exit 0
Expand All @@ -28,7 +28,8 @@ git log -1 --pretty='%h ("%s")' HEAD
pr "Checking before the patch"
git checkout -q HEAD~

for f in $(git show --diff-filter=M --pretty="" --name-only HEAD | grep -E "\.py$"); do
# Also ignore created, as not present in the parent commit
for f in $(git show --diff-filter=M --pretty="" --name-only "${HEAD}" | grep -E "\.py$"); do
pylint $f | tee -a $tmpfile_o
done

Expand All @@ -38,7 +39,7 @@ incumbent_w=$(grep -i -c ": [WC][0-9][0-9][0-9][0-9]: " $tmpfile_o)
pr "Checking the tree with the patch"
git checkout -q $HEAD

for f in $(git show --diff-filter=AM --pretty="" --name-only HEAD | grep -E "\.py$"); do
for f in $(git show --diff-filter=AM --pretty="" --name-only "${HEAD}" | grep -E "\.py$"); do
pylint $f | tee -a $tmpfile_n
done

Expand Down
9 changes: 5 additions & 4 deletions tests/patch/shellcheck/shellcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pr() {
echo " ====== $@ ======" | tee -a /dev/stderr
}

# If it doesn't touch .sh files, don't bother. Ignore created and deleted.
if ! git show --diff-filter=AM --pretty="" --name-only HEAD | grep -q -E "\.sh$"
# If it doesn't touch .sh files, don't bother. Ignore deleted.
if ! git show --diff-filter=AM --pretty="" --name-only "${HEAD}" | grep -q -E "\.sh$"
then
echo "No shell scripts touched, skip" >&$DESC_FD
exit 0
Expand All @@ -28,7 +28,8 @@ git log -1 --pretty='%h ("%s")' HEAD
pr "Checking before the patch"
git checkout -q HEAD~

for f in $(git show --diff-filter=M --pretty="" --name-only HEAD | grep -E "\.sh$"); do
# Also ignore created, as not present in the parent commit
for f in $(git show --diff-filter=M --pretty="" --name-only "${HEAD}" | grep -E "\.sh$"); do
(
echo "Checking $f"
echo
Expand All @@ -45,7 +46,7 @@ incumbent_w=$(grep -i -c "SC[0-9]* (" $tmpfile_o)
pr "Building the tree with the patch"
git checkout -q $HEAD

for f in $(git show --diff-filter=AM --pretty="" --name-only HEAD | grep -E "\.sh$"); do
for f in $(git show --diff-filter=AM --pretty="" --name-only "${HEAD}" | grep -E "\.sh$"); do
(
echo "Checking $f"
echo
Expand Down
9 changes: 5 additions & 4 deletions tests/patch/yamllint/yamllint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pr() {
echo " ====== $@ ======" | tee -a /dev/stderr
}

# If it doesn't touch .yaml files, don't bother. Ignore created and deleted.
if ! git show --diff-filter=AM --pretty="" --name-only HEAD | grep -q -E "\.yaml$"
# If it doesn't touch .yaml files, don't bother. Ignore deleted.
if ! git show --diff-filter=AM --pretty="" --name-only "${HEAD}" | grep -q -E "\.yaml$"
then
echo "No YAML files touched, skip" >&$DESC_FD
exit 0
Expand All @@ -28,7 +28,8 @@ git log -1 --pretty='%h ("%s")' HEAD
pr "Checking before the patch"
git checkout -q HEAD~

for f in $(git show --diff-filter=M --pretty="" --name-only HEAD | grep -E "\.yaml$"); do
# Also ignore created, as not present in the parent commit
for f in $(git show --diff-filter=M --pretty="" --name-only "${HEAD}" | grep -E "\.yaml$"); do
yamllint $f | tee -a $tmpfile_o
done

Expand All @@ -38,7 +39,7 @@ incumbent_w=$(grep -i -c " warning " $tmpfile_o)
pr "Checking the tree with the patch"
git checkout -q $HEAD

for f in $(git show --diff-filter=AM --pretty="" --name-only HEAD | grep -E "\.yaml$"); do
for f in $(git show --diff-filter=AM --pretty="" --name-only "${HEAD}" | grep -E "\.yaml$"); do
yamllint $f | tee -a $tmpfile_n
done

Expand Down