zulip/tools/commit-message-lint

26 lines
662 B
Bash
Executable File

#!/usr/bin/env bash
# Lint all commit messages that are newer than upstream/master if running
# locally or the commits in the push or PR if in CircleCI.
# The rules can be found in /.gitlint
repository="zulip/zulip"
if [[ "
$(git remote -v)
" =~ '
'([^[:space:]]*)[[:space:]]*(https://github\.com/|ssh://git@github\.com/|git@github\.com:)"$repository"(\.git|/)?\ \(fetch\)'
' ]]; then
range="${BASH_REMATCH[1]}/master..HEAD"
else
range="upstream/master..HEAD"
fi
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