mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/10093] Refactor complaining in commit-msg hook for color support.
PHPBB3-10093
This commit is contained in:
parent
26d01d4408
commit
6a3ee0996e
1 changed files with 22 additions and 17 deletions
|
@ -60,6 +60,11 @@ quit()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
complain()
|
||||||
|
{
|
||||||
|
echo "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# Check for empty commit message
|
# Check for empty commit message
|
||||||
if ! grep -qv '^#' "$1"
|
if ! grep -qv '^#' "$1"
|
||||||
then
|
then
|
||||||
|
@ -75,9 +80,9 @@ msg=$(grep -v '^#' "$1" |grep -nE '.{81,}')
|
||||||
|
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "The following lines are greater than 80 characters long:" >&2;
|
complain "The following lines are greater than 80 characters long:" >&2;
|
||||||
echo >&2
|
complain >&2
|
||||||
echo "$msg" >&2;
|
complain "$msg" >&2;
|
||||||
|
|
||||||
quit $ERR_LENGTH;
|
quit $ERR_LENGTH;
|
||||||
fi
|
fi
|
||||||
|
@ -131,9 +136,9 @@ do
|
||||||
# Don't be too strict.
|
# Don't be too strict.
|
||||||
# Commits may be temporary, intended to be squashed later.
|
# Commits may be temporary, intended to be squashed later.
|
||||||
# Just issue a warning here.
|
# Just issue a warning here.
|
||||||
echo "Warning: heading should be a sentence beginning with a capital letter." 1>&2
|
complain "Warning: heading should be a sentence beginning with a capital letter." 1>&2
|
||||||
echo "You entered:" 1>&2
|
complain "You entered:" 1>&2
|
||||||
echo "$line" 1>&2
|
complain "$line" 1>&2
|
||||||
fi
|
fi
|
||||||
# restore exit code
|
# restore exit code
|
||||||
(exit $result)
|
(exit $result)
|
||||||
|
@ -165,7 +170,7 @@ do
|
||||||
echo "$line" | grep -Eq "^#";
|
echo "$line" | grep -Eq "^#";
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unrecognised token $expect" >&2;
|
complain "Unrecognised token $expect" >&2;
|
||||||
quit $err;
|
quit $err;
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -236,7 +241,7 @@ do
|
||||||
expecting="eof";
|
expecting="eof";
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unrecognised token $expect" >&2;
|
complain "Unrecognised token $expect" >&2;
|
||||||
quit 254;
|
quit 254;
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -250,10 +255,10 @@ do
|
||||||
else
|
else
|
||||||
# None of the expected line formats matched
|
# None of the expected line formats matched
|
||||||
# Guess we'll call it a day here then
|
# Guess we'll call it a day here then
|
||||||
echo "Syntax error on line $i:" >&2;
|
complain "Syntax error on line $i:" >&2;
|
||||||
echo ">> $line" >&2;
|
complain ">> $line" >&2;
|
||||||
echo -n "Expecting: " >&2;
|
complain -n "Expecting: " >&2;
|
||||||
echo "$expecting" | sed 's/ /, /g' >&2;
|
complain "$expecting" | sed 's/ /, /g' >&2;
|
||||||
quit $err;
|
quit $err;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -263,7 +268,7 @@ done
|
||||||
# If EOF is expected exit cleanly
|
# If EOF is expected exit cleanly
|
||||||
echo "$expecting" | grep -q "eof" || (
|
echo "$expecting" | grep -q "eof" || (
|
||||||
# Unexpected EOF, error
|
# Unexpected EOF, error
|
||||||
echo "Unexpected EOF encountered" >&2;
|
complain "Unexpected EOF encountered" >&2;
|
||||||
quit $ERR_EOF;
|
quit $ERR_EOF;
|
||||||
) && (
|
) && (
|
||||||
# Do post scan checks
|
# Do post scan checks
|
||||||
|
@ -274,8 +279,8 @@ echo "$expecting" | grep -q "eof" || (
|
||||||
|
|
||||||
if [ ! -z "$dupes" ]
|
if [ ! -z "$dupes" ]
|
||||||
then
|
then
|
||||||
echo "The following tickets are repeated:" >&2;
|
complain "The following tickets are repeated:" >&2;
|
||||||
echo "$dupes" | sed 's/ /\n/g;s/^/* /g' >&2;
|
complain "$dupes" | sed 's/ /\n/g;s/^/* /g' >&2;
|
||||||
quit $ERR_FOOTER;
|
quit $ERR_FOOTER;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -283,8 +288,8 @@ echo "$expecting" | grep -q "eof" || (
|
||||||
if [ $ticket -gt 0 ]
|
if [ $ticket -gt 0 ]
|
||||||
then
|
then
|
||||||
echo "$tickets" | grep -Eq "\bPHPBB3-$ticket\b" || (
|
echo "$tickets" | grep -Eq "\bPHPBB3-$ticket\b" || (
|
||||||
echo "Ticket ID [$ticket] of branch missing from list of tickets:" >&2;
|
complain "Ticket ID [$ticket] of branch missing from list of tickets:" >&2;
|
||||||
echo "$tickets" | sed 's/ /\n/g;s/^/* /g' >&2;
|
complain "$tickets" | sed 's/ /\n/g;s/^/* /g' >&2;
|
||||||
quit $ERR_FOOTER;
|
quit $ERR_FOOTER;
|
||||||
) || exit $?;
|
) || exit $?;
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue