mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
chore: actually restrict length the first line of Merge*
commits
Regexp didn't actually restrict it, found by @iphydf. Verification now treats commit & merge messages differently, since as pointed out by @initramfs treating them the same could result in marking as valid a non-merge commit that starts with `Merge`. `s/Pls/Please/` as requested by @initramfs. Also require a space between `Merge` word and rest of the commit message.
This commit is contained in:
parent
d66a981d17
commit
e4398c7894
@ -15,8 +15,8 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Script for verifying conformance to commit message format of commits in commit
|
# Script for verifying conformance to commit message format of commits in
|
||||||
# range supplied.
|
# commit range supplied.
|
||||||
#
|
#
|
||||||
# Script fails (non-zero exit status) if commit messages don't conform.
|
# Script fails (non-zero exit status) if commit messages don't conform.
|
||||||
|
|
||||||
@ -25,19 +25,30 @@
|
|||||||
#
|
#
|
||||||
# $commit_range – in format `abdce..12345`
|
# $commit_range – in format `abdce..12345`
|
||||||
|
|
||||||
|
|
||||||
|
# Fail as soon as an error appears
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
ARG="$1"
|
ARG="$1"
|
||||||
|
|
||||||
echo "" # ← formatting
|
echo "" # ← formatting
|
||||||
|
|
||||||
|
grep_for_invalid() {
|
||||||
|
# differentiate what is allowed for commit messages and merge messages
|
||||||
|
git log --no-merges --format=format:'%s' "$ARG" \
|
||||||
|
| grep -v -E '^(feat|fix|docs|style|refactor|perf|revert|test|chore)(\(.{,12}\))?:.{1,68}$' \
|
||||||
|
|| git log --merges --format=format:'%s' "$ARG" \
|
||||||
|
| grep -v -E '^Merge .{1,70}$'
|
||||||
|
}
|
||||||
|
|
||||||
# Conform, /OR ELSE/.
|
# Conform, /OR ELSE/.
|
||||||
if git log --format=format:'%s' "$ARG" | \
|
if grep_for_invalid
|
||||||
grep -v -E '^((feat|fix|docs|style|refactor|perf|revert|test|chore)(\(.{,12}\))?:.{1,68})|(Merge(.+){,70})$'
|
|
||||||
then
|
then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Above ↑ commits don't conform to commit message format:"
|
echo "Above ↑ commits don't conform to commit message format:"
|
||||||
echo "https://github.com/qTox/qTox/blob/master/CONTRIBUTING.md#commit-message-format"
|
echo "https://github.com/qTox/qTox/blob/master/CONTRIBUTING.md#commit-message-format"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Pls fix."
|
echo "Please fix."
|
||||||
echo ""
|
echo ""
|
||||||
echo "If you're not sure how to rewrite history, here's a helpful tutorial:"
|
echo "If you're not sure how to rewrite history, here's a helpful tutorial:"
|
||||||
echo "https://www.atlassian.com/git/tutorials/rewriting-history/git-commit--amend/"
|
echo "https://www.atlassian.com/git/tutorials/rewriting-history/git-commit--amend/"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user