mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 23:31:04 +00:00
8110205820
* Run script in strict mode * Add proper seperator between revision and file * Fix copy paste error * Do not repeat limit number in error text * Fix bad revision error * Do not mask pipe errors * Fix typo * Remove unnecessary ... syntax * Do not fetch all commits of master * Fetching one commit is enough
55 lines
1.4 KiB
Bash
Executable File
55 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# check if line width of rust source files is not beyond x characters
|
|
#
|
|
set -e
|
|
set -o pipefail
|
|
|
|
BASE_ORIGIN="origin"
|
|
BASE_BRANCH_NAME="master"
|
|
LINE_WIDTH="120"
|
|
GOOD_LINE_WIDTH="100"
|
|
BASE_BRANCH="${BASE_ORIGIN}/${BASE_BRANCH_NAME}"
|
|
|
|
git fetch ${BASE_ORIGIN} ${BASE_BRANCH_NAME} --depth 1
|
|
git diff --name-only ${BASE_BRANCH} -- \*.rs | ( while read file
|
|
do
|
|
if [ ! -f ${file} ];
|
|
then
|
|
echo "Skipping removed file."
|
|
elif git diff ${BASE_BRANCH} -- ${file} | grep -q "^+.\{$(( $LINE_WIDTH + 1 ))\}"
|
|
then
|
|
if [ -z "${FAIL}" ]
|
|
then
|
|
echo "| error!"
|
|
echo "| Lines must not be longer than ${LINE_WIDTH} characters."
|
|
echo "| "
|
|
echo "| see more https://wiki.parity.io/Substrate-Style-Guide"
|
|
echo "|"
|
|
FAIL="true"
|
|
fi
|
|
echo "| file: ${file}"
|
|
git diff ${BASE_BRANCH} -- ${file} \
|
|
| grep -n "^+.\{$(( $LINE_WIDTH + 1))\}"
|
|
echo "|"
|
|
else
|
|
if git diff ${BASE_BRANCH} -- ${file} | grep -q "^+.\{$(( $GOOD_LINE_WIDTH + 1 ))\}"
|
|
then
|
|
if [ -z "${FAIL}" ]
|
|
then
|
|
echo "| warning!"
|
|
echo "| Lines should be longer than ${GOOD_LINE_WIDTH} characters only in exceptional circumstances!"
|
|
echo "| "
|
|
echo "| see more https://wiki.parity.io/Substrate-Style-Guide"
|
|
echo "|"
|
|
fi
|
|
echo "| file: ${file}"
|
|
git diff ${BASE_BRANCH} -- ${file} | grep -n "^+.\{$(( $GOOD_LINE_WIDTH + 1 ))\}"
|
|
echo "|"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
test -z "${FAIL}"
|
|
)
|