mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge branch 'ticket/p/9824' into develop-olympus
* ticket/p/9824: [ticket/9824] Accept commit messages with less than perfect headings. [ticket/9824] Allow empty lines after ticket reference. [ticket/9824] Use printf instead of echo to render \n. [ticket/9824] Handle empty commit messages in commit-msg hook. [ticket/9824] Add space after [ticket/12345] in prepared commit message. [ticket/9824] Remove space after PHPBB3-12345 in prepared commit message.
This commit is contained in:
commit
12721f654e
2 changed files with 34 additions and 4 deletions
|
@ -55,6 +55,17 @@ quit()
|
|||
fi
|
||||
}
|
||||
|
||||
# Check for empty commit message
|
||||
if ! grep -qv '^#' "$1"
|
||||
then
|
||||
# Commit message is empty (or contains only comments).
|
||||
# Let git handle this.
|
||||
# It will abort with a message like so:
|
||||
#
|
||||
# Aborting commit due to empty commit message.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
msg=$(grep -nE '.{81,}' "$1");
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
|
@ -107,7 +118,19 @@ do
|
|||
case $expect in
|
||||
"header")
|
||||
err=$ERR_HEADER;
|
||||
echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$"
|
||||
echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] .+$"
|
||||
result=$?
|
||||
if ! echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$"
|
||||
then
|
||||
# Don't be too strict.
|
||||
# Commits may be temporary, intended to be squashed later.
|
||||
# Just issue a warning here.
|
||||
echo "Warning: heading should be a sentence beginning with a capital letter." 1>&2
|
||||
echo "You entered:" 1>&2
|
||||
echo "$line" 1>&2
|
||||
fi
|
||||
# restore exit code
|
||||
(exit $result)
|
||||
;;
|
||||
"empty")
|
||||
err=$ERR_EMPTY;
|
||||
|
@ -128,6 +151,10 @@ do
|
|||
# Should not end up here
|
||||
false
|
||||
;;
|
||||
"possibly-eof")
|
||||
# Allow empty and/or comment lines at the end
|
||||
! tail -n +"$i" "$1" |grep -qvE '^($|#)'
|
||||
;;
|
||||
"comment")
|
||||
echo "$line" | grep -Eq "^#";
|
||||
;;
|
||||
|
@ -188,7 +215,7 @@ do
|
|||
in_description=1;
|
||||
;;
|
||||
"footer")
|
||||
expecting="footer eof";
|
||||
expecting="footer possibly-eof";
|
||||
if [ "$tickets" = "" ]
|
||||
then
|
||||
tickets="$line";
|
||||
|
@ -199,6 +226,9 @@ do
|
|||
"comment")
|
||||
# Comments should expect the same thing again
|
||||
;;
|
||||
"possibly-eof")
|
||||
expecting="eof";
|
||||
;;
|
||||
*)
|
||||
echo "Unrecognised token $expect" >&2;
|
||||
quit 254;
|
||||
|
|
|
@ -35,7 +35,7 @@ then
|
|||
# Branch is prefixed with 'ticket/', append ticket ID to message
|
||||
if [ "$branch" != "${branch##ticket/}" ];
|
||||
then
|
||||
tail="\n\nPHPBB3-${branch##ticket/}";
|
||||
tail="$(printf "\n\nPHPBB3-${branch##ticket/}")";
|
||||
fi
|
||||
|
||||
echo "[$branch] $tail$(cat "$1")" > "$1"
|
||||
|
|
Loading…
Add table
Reference in a new issue