ci: make the whitespace report optional
The `check-whitespace` CI job generates a formatted output file containing whitespace error information. As not all CI providers support rendering a formatted summary, make its generation optional. Signed-off-by: Justin Tobler <jltobler@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
66820fb7bf
commit
9bef98096c
@ -1,9 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Check that commits after a specified point do not contain new or modified
|
||||||
|
# lines with whitespace errors. An optional formatted summary can be generated
|
||||||
|
# by providing an output file path and url as additional arguments.
|
||||||
|
#
|
||||||
|
|
||||||
baseCommit=$1
|
baseCommit=$1
|
||||||
outputFile=$2
|
outputFile=$2
|
||||||
url=$3
|
url=$3
|
||||||
|
|
||||||
|
if test "$#" -ne 1 && test "$#" -ne 3
|
||||||
|
then
|
||||||
|
echo "USAGE: $0 <BASE_COMMIT> [<OUTPUT_FILE> <URL>]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
problems=()
|
problems=()
|
||||||
commit=
|
commit=
|
||||||
commitText=
|
commitText=
|
||||||
@ -56,19 +67,29 @@ then
|
|||||||
goodParent=${baseCommit: 0:7}
|
goodParent=${baseCommit: 0:7}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "A whitespace issue was found in onen of more of the commits."
|
||||||
|
echo "Run the following command to resolve whitespace issues:"
|
||||||
|
echo "git rebase --whitespace=fix ${goodParent}"
|
||||||
|
|
||||||
|
# If target output file is provided, write formatted output.
|
||||||
|
if test -n "$outputFile"
|
||||||
|
then
|
||||||
echo "🛑 Please review the Summary output for further information."
|
echo "🛑 Please review the Summary output for further information."
|
||||||
echo "### :x: A whitespace issue was found in one or more of the commits." >"$outputFile"
|
(
|
||||||
echo "" >>"$outputFile"
|
echo "### :x: A whitespace issue was found in one or more of the commits."
|
||||||
echo "Run these commands to correct the problem:" >>"$outputFile"
|
echo ""
|
||||||
echo "1. \`git rebase --whitespace=fix ${goodParent}\`" >>"$outputFile"
|
echo "Run these commands to correct the problem:"
|
||||||
echo "1. \`git push --force\`" >>"$outputFile"
|
echo "1. \`git rebase --whitespace=fix ${goodParent}\`"
|
||||||
echo " " >>"$outputFile"
|
echo "1. \`git push --force\`"
|
||||||
echo "Errors:" >>"$outputFile"
|
echo ""
|
||||||
|
echo "Errors:"
|
||||||
|
|
||||||
for i in "${problems[@]}"
|
for i in "${problems[@]}"
|
||||||
do
|
do
|
||||||
echo "${i}" >>"$outputFile"
|
echo "${i}"
|
||||||
done
|
done
|
||||||
|
) >"$outputFile"
|
||||||
|
fi
|
||||||
|
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user