2016-04-14 07:42:53 +08:00
|
|
|
|
#!/bin/bash
|
2019-06-24 22:01:18 +08:00
|
|
|
|
|
|
|
|
|
# Copyright © 2016 Zetok Zalbavar <zetok@openmailbox.org>
|
|
|
|
|
# Copyright © 2019 by The qTox Project Contributors
|
2016-04-14 07:42:53 +08:00
|
|
|
|
#
|
2019-06-24 22:01:18 +08:00
|
|
|
|
# This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
# qTox is libre software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
2016-04-14 07:42:53 +08:00
|
|
|
|
#
|
2019-06-24 22:01:18 +08:00
|
|
|
|
# qTox is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
2016-04-14 07:42:53 +08:00
|
|
|
|
#
|
2019-06-24 22:01:18 +08:00
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with qTox. If not, see <http://www.gnu.org/licenses/>
|
2016-04-14 07:42:53 +08:00
|
|
|
|
|
2016-08-11 13:50:35 +08:00
|
|
|
|
# Script for verifying conformance to commit message format of commits in
|
|
|
|
|
# commit range supplied.
|
2016-04-14 07:42:53 +08:00
|
|
|
|
#
|
2016-07-30 01:57:42 +08:00
|
|
|
|
# Script fails (non-zero exit status) if commit messages don't conform.
|
2016-04-14 07:42:53 +08:00
|
|
|
|
|
|
|
|
|
# usage:
|
|
|
|
|
# ./$script $commit_range
|
|
|
|
|
#
|
|
|
|
|
# $commit_range – in format `abdce..12345`
|
|
|
|
|
|
2016-08-11 13:50:35 +08:00
|
|
|
|
|
|
|
|
|
# Fail as soon as an error appears
|
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
2016-04-14 07:42:53 +08:00
|
|
|
|
ARG="$1"
|
|
|
|
|
|
|
|
|
|
echo "" # ← formatting
|
|
|
|
|
|
2016-08-11 13:50:35 +08:00
|
|
|
|
grep_for_invalid() {
|
2020-04-13 15:51:48 +08:00
|
|
|
|
# we can't rely on differentiating merge and normal commits since short clones that travis does may not be able
|
|
|
|
|
# to tell if the oldest commit is a merge commit or not
|
|
|
|
|
git log --format=format:'%s' "$ARG" \
|
|
|
|
|
| grep -v -E '^((feat|fix|docs|style|refactor|perf|revert|test|chore)(\(.{,12}\))?:.{1,68})|(Merge .{1,70})$'
|
2016-08-11 13:50:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-14 07:42:53 +08:00
|
|
|
|
# Conform, /OR ELSE/.
|
2016-08-11 13:50:35 +08:00
|
|
|
|
if grep_for_invalid
|
2016-04-14 07:42:53 +08:00
|
|
|
|
then
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Above ↑ commits don't conform to commit message format:"
|
2016-08-04 06:25:50 +08:00
|
|
|
|
echo "https://github.com/qTox/qTox/blob/master/CONTRIBUTING.md#commit-message-format"
|
2016-04-14 07:42:53 +08:00
|
|
|
|
echo ""
|
2016-08-11 13:50:35 +08:00
|
|
|
|
echo "Please fix."
|
2016-04-14 07:42:53 +08:00
|
|
|
|
echo ""
|
|
|
|
|
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 ""
|
|
|
|
|
echo "If you're still not sure what to do, feel free to pop on IRC, or ask in PR comments for help :)"
|
|
|
|
|
# fail the build
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|