2021-02-24 23:13:09 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This file is copied from the original tools/commit-message-lint at zulip/zulip,
|
|
|
|
# Edited at Line 14 Col 97 (zulip -> python-zulip-api)
|
|
|
|
# Please don't edit here; instead update the zulip/zulip copy and then resync this file.
|
|
|
|
|
2021-08-24 15:50:52 -04:00
|
|
|
# Lint all commit messages that are newer than upstream/main if running
|
2021-02-24 23:13:09 -05:00
|
|
|
# locally or the commits in the push or PR Gh-Actions.
|
|
|
|
|
|
|
|
# The rules can be found in /.gitlint
|
|
|
|
|
2021-05-06 11:20:35 -04:00
|
|
|
repository="zulip/python-zulip-api"
|
|
|
|
|
2021-02-24 23:13:09 -05:00
|
|
|
if [[ "
|
|
|
|
$(git remote -v)
|
|
|
|
" =~ '
|
2021-05-06 11:20:35 -04:00
|
|
|
'([^[:space:]]*)[[:space:]]*(https://github\.com/|ssh://git@github\.com/|git@github\.com:)"$repository"(\.git|/)?\ \(fetch\)'
|
2021-02-24 23:13:09 -05:00
|
|
|
' ]]; then
|
2021-08-24 15:50:52 -04:00
|
|
|
range="${BASH_REMATCH[1]}/main..HEAD"
|
2021-02-24 23:13:09 -05:00
|
|
|
else
|
2021-08-24 15:50:52 -04:00
|
|
|
range="upstream/main..HEAD"
|
2021-02-24 23:13:09 -05:00
|
|
|
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
|