2018-12-18 02:08:53 +01:00
|
|
|
#!/usr/bin/env bash
|
2017-03-22 21:18:48 +01:00
|
|
|
|
2017-04-22 21:36:52 +02:00
|
|
|
# Lint all commit messages that are newer than upstream/master if running
|
2020-04-28 20:26:58 +02:00
|
|
|
# locally or the commits in the push or PR if in CircleCI.
|
2017-04-22 21:36:52 +02:00
|
|
|
|
2017-03-22 21:18:48 +01:00
|
|
|
# The rules can be found in /.gitlint
|
|
|
|
|
2020-04-26 19:16:36 +02:00
|
|
|
if [[ "
|
2020-02-04 13:48:17 +01:00
|
|
|
$(git remote -v)
|
|
|
|
" =~ '
|
|
|
|
'([^[:space:]]*)[[:space:]]*(https://github\.com/|ssh://git@github\.com/|git@github\.com:)zulip/zulip(\.git|/)?\ \(fetch\)'
|
|
|
|
' ]]; then
|
|
|
|
range="${BASH_REMATCH[1]}/master..HEAD"
|
2017-04-22 21:36:52 +02:00
|
|
|
else
|
2017-04-26 01:50:16 +02:00
|
|
|
range="upstream/master..HEAD"
|
2017-03-22 21:18:48 +01:00
|
|
|
fi
|
|
|
|
|
2018-03-02 20:49:46 +01:00
|
|
|
commits=$(git log "$range" | wc -l)
|
|
|
|
if [ "$commits" -gt 0 ]; then
|
|
|
|
# Only run gitlint with non-empty commit lists, to avoid a printed
|
|
|
|
# warning.
|
|
|
|
gitlint --commits "$range"
|
|
|
|
fi
|