From abcfbe9f92136c787723683b7e4c4aeee2eb0dd5 Mon Sep 17 00:00:00 2001 From: Zetok Zalbavar Date: Thu, 14 Apr 2016 00:42:53 +0100 Subject: [PATCH] chore(travis): verify conformance to commit message format Added script that can be used to verify correctness of commit messages in given range. --- .travis.yml | 1 + verify-commit-messages.sh | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 verify-commit-messages.sh diff --git a/.travis.yml b/.travis.yml index 1d573a497..8ca797e76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ os: - osx script: +- if [[ "$TRAVIS_PULL_REQUEST" != "false" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash ./verify-commit-messages.sh "$TRAVIS_COMMIT_RANGE" ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash ./.travis/build-ubuntu_14_04.sh; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bash ./osx/qTox-Mac-Deployer-ULTIMATE.sh -i ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then bash ./osx/qTox-Mac-Deployer-ULTIMATE.sh -b ; fi diff --git a/verify-commit-messages.sh b/verify-commit-messages.sh new file mode 100755 index 000000000..3ee523ca0 --- /dev/null +++ b/verify-commit-messages.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Copyright © 2016 Zetok Zalbavar +# +# This program is free 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. +# +# This program 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. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Script for verifying conformance to commit message format of commits in commit +# range supplied. +# +# Scrpt fails (non-zero exit status) if commit messages don't conform. + +# usage: +# ./$script $commit_range +# +# $commit_range – in format `abdce..12345` + +ARG="$1" + +echo "" # ← formatting + +# Conform, /OR ELSE/. +if git log --format=format:'%s' "$ARG" | \ + grep -v -E '^(feat|fix|docs|style|refactor|perf|revert|test|chore)(\(.+\))?:.{1,68}$' +then + echo "" + echo "Above ↑ commits don't conform to commit message format:" + echo "https://github.com/tux3/qTox/blob/master/CONTRIBUTING.md#commit-message-format" + echo "" + echo "Pls fix." + 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