mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +00:00
Fix gitlab line-width CI check (#5994)
* 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
This commit is contained in:
committed by
GitHub
parent
b718c45dbd
commit
8110205820
@@ -2,47 +2,49 @@
|
|||||||
#
|
#
|
||||||
# check if line width of rust source files is not beyond x characters
|
# 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}"
|
||||||
|
|
||||||
BASE_BRANCH="origin/master"
|
git fetch ${BASE_ORIGIN} ${BASE_BRANCH_NAME} --depth 1
|
||||||
LINE_WIDTH="121"
|
git diff --name-only ${BASE_BRANCH} -- \*.rs | ( while read file
|
||||||
GOOD_LINE_WIDTH="101"
|
|
||||||
|
|
||||||
|
|
||||||
git diff --name-only ${BASE_BRANCH}...${CI_COMMIT_SHA} \*.rs | ( while read file
|
|
||||||
do
|
do
|
||||||
if [ ! -f ${file} ];
|
if [ ! -f ${file} ];
|
||||||
then
|
then
|
||||||
echo "Skipping removed file."
|
echo "Skipping removed file."
|
||||||
elif git diff ${BASE_BRANCH}...${CI_COMMIT_SHA} ${file} | grep -q "^+.\{${LINE_WIDTH}\}"
|
elif git diff ${BASE_BRANCH} -- ${file} | grep -q "^+.\{$(( $LINE_WIDTH + 1 ))\}"
|
||||||
then
|
then
|
||||||
if [ -z "${FAIL}" ]
|
if [ -z "${FAIL}" ]
|
||||||
then
|
then
|
||||||
echo "| warning!"
|
echo "| error!"
|
||||||
echo "| Lines should not be longer than 120 characters."
|
echo "| Lines must not be longer than ${LINE_WIDTH} characters."
|
||||||
echo "| "
|
echo "| "
|
||||||
echo "| see more https://wiki.parity.io/Substrate-Style-Guide"
|
echo "| see more https://wiki.parity.io/Substrate-Style-Guide"
|
||||||
echo "|"
|
echo "|"
|
||||||
FAIL="true"
|
FAIL="true"
|
||||||
fi
|
fi
|
||||||
echo "| file: ${file}"
|
echo "| file: ${file}"
|
||||||
git diff ${BASE_BRANCH}...${CI_COMMIT_SHA} ${file} \
|
git diff ${BASE_BRANCH} -- ${file} \
|
||||||
| grep -n "^+.\{${LINE_WIDTH}\}"
|
| grep -n "^+.\{$(( $LINE_WIDTH + 1))\}"
|
||||||
echo "|"
|
echo "|"
|
||||||
else
|
else
|
||||||
if git diff ${BASE_BRANCH}...${CI_COMMIT_SHA} ${file} | grep -q "^+.\{${GOOD_LINE_WIDTH}\}"
|
if git diff ${BASE_BRANCH} -- ${file} | grep -q "^+.\{$(( $GOOD_LINE_WIDTH + 1 ))\}"
|
||||||
then
|
then
|
||||||
if [ -z "${FAIL}" ]
|
if [ -z "${FAIL}" ]
|
||||||
then
|
then
|
||||||
echo "| warning!"
|
echo "| warning!"
|
||||||
echo "| Lines should be longer than 100 characters only in exceptional circumstances!"
|
echo "| Lines should be longer than ${GOOD_LINE_WIDTH} characters only in exceptional circumstances!"
|
||||||
echo "| "
|
echo "| "
|
||||||
echo "| see more https://wiki.parity.io/Substrate-Style-Guide"
|
echo "| see more https://wiki.parity.io/Substrate-Style-Guide"
|
||||||
echo "|"
|
echo "|"
|
||||||
fi
|
fi
|
||||||
echo "| file: ${file}"
|
echo "| file: ${file}"
|
||||||
git diff ${BASE_BRANCH}...${CI_COMMIT_SHA} ${file} \
|
git diff ${BASE_BRANCH} -- ${file} | grep -n "^+.\{$(( $GOOD_LINE_WIDTH + 1 ))\}"
|
||||||
| grep -n "^+.\{${LINE_WIDTH}\}"
|
|
||||||
echo "|"
|
echo "|"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user