1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 06:53:52 +01:00

Merge pull request #15795 from miri64/dist/fix/diff-output

static_tests: fix diff output
This commit is contained in:
Francisco 2021-02-24 08:17:37 +01:00 committed by GitHub
commit 8dec3f2833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 10 deletions

View File

@ -31,9 +31,9 @@ _annotate_diff() {
if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
MSG="Coccinelle proposes the following patch:\n\n$3"
if [ $COCCINELLE_WARNONLY -eq 0 ]; then
github_annotate_error "$1" "$2" "${MSG}"
IFS="${OLD_IFS}" github_annotate_error "$1" "$2" "${MSG}"
else
github_annotate_warning "$1" "$2" "${MSG}"
IFS="${OLD_IFS}" github_annotate_warning "$1" "$2" "${MSG}"
fi
fi
}
@ -59,7 +59,9 @@ coccinelle_checkone() {
echo "$OUT" | {
# see https://stackoverflow.com/a/30064493/11921757 for why we
# use a sub shell here
while read line; do
OLD_IFS="${IFS}" # store old separator to later restore it
IFS='' # keep leading and trailing spaces
while read -r line; do
# parse beginning of new diff
if echo "$line" | grep -q '^--- .\+$'; then
_annotate_diff "$DIFFFILE" "$DIFFLINE" "$DIFF"
@ -84,7 +86,7 @@ coccinelle_checkone() {
fi
DIFFLINE="$(echo "$line" | sed 's/@@ -\([0-9]\+\).*$/\1/')"
fi
DIFF="$DIFF\n$line"
DIFF="$DIFF\n${line//\\/\\\\}"
fi
done
_annotate_diff "$DIFFFILE" "$DIFFLINE" "$DIFF"

View File

@ -25,7 +25,7 @@ filter() {
_annotate_diff() {
if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
github_annotate_error "$1" "$2" "Wrong header guard format:\n\n$3"
IFS="${OLD_IFS}" github_annotate_error "$1" "$2" "Wrong header guard format:\n\n$3"
fi
}
@ -40,7 +40,9 @@ _headercheck() {
echo "$OUT" | {
# see https://stackoverflow.com/a/30064493/11921757 for why we
# use a sub shell here
while read line; do
OLD_IFS="$IFS" # store old separator to later restore it
IFS='' # keep leading and trailing spaces
while read -r line; do
# file has no or broken header guard
if echo "$line" | grep -q '^.*: no / broken header guard$'; then
# this output comes outside of a diff, so reset diff parser
@ -71,7 +73,7 @@ _headercheck() {
fi
DIFFLINE="$(echo "$line" | sed 's/@@ -\([0-9]\+\).*$/\1/')"
fi
DIFF="$DIFF\n$line"
DIFF="$DIFF\n$(echo "${line}"| sed 's/\\/\\\\/g' )"
fi
done
_annotate_diff "$DIFFFILE" "$DIFFLINE" "$DIFF"

View File

@ -32,7 +32,7 @@ check () {
_annotate_diff() {
if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
MSG="Uncrustify proposes the following patch:\n\n$3"
github_annotate_error "$1" "$2" "${MSG}"
IFS="${OLD_IFS}" github_annotate_error "$1" "$2" "${MSG}"
fi
}
@ -52,7 +52,9 @@ exec_uncrustify () {
git diff HEAD | {
# see https://stackoverflow.com/a/30064493/11921757 for why we
# use a sub shell here
while read line; do
OLD_IFS="$IFS" # store old separator to later restore it
IFS='' # keep leading and trailing spaces
while read -r line; do
# parse beginning of new diff
if echo "$line" | grep -q '^--- .\+$'; then
_annotate_diff "$DIFFFILE" "$DIFFLINE" "$DIFF"
@ -74,7 +76,7 @@ exec_uncrustify () {
fi
DIFFLINE="$(echo "$line" | sed 's/@@ -\([0-9]\+\).*$/\1/')"
fi
DIFF="$DIFF\n$line"
DIFF="$DIFF\n${line//\\/\\\\}"
fi
done
_annotate_diff "$DIFFFILE" "$DIFFLINE" "$DIFF"