mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
a53ef19d99
BACKPORT NOTICE There's some difference with original PR but that's not important because we do not actually use travis. The variable TRAVIS_BRANCH would be removed anyway in bitcoin#20697 - let's just skip it for simplicity -------------- a91ab86fae91d416d664d19d2f482a8d19c115a6 lint: Use TRAVIS_BRANCH in lint-git-commit-check.sh (Fabian Jahr) c11dc995c98e908dfd9cea64d4b34329b1dbb5c6 lint: Don't use TRAVIS_COMMIT_RANGE in whitespace linter (Fabian Jahr) 1b41ce8f5f3debae03ca60e4acada14680df9185 lint: Don't use TRAVIS_COMMIT_RANGE for commit-script-check (Fabian Jahr) Pull request description: This is causing problems again, very similar to #19654. UPDATE: This now removes all remaining usages of TRAVIS_COMMIT_RANGE and instead uses TRAVIS_BRANCH for the range, including `lint-git-commit-check` where TRAVIS_COMMIT_RANGE had already been removed. For builds triggered by a pull request, TRAVIS_BRANCH is the name of the branch targeted by the pull request. In the linters there is still a fallback that assumes master as the target branch. ACKs for top commit: sipa: ACK a91ab86fae91d416d664d19d2f482a8d19c115a6. See test I tried in #20075. Tree-SHA512: 1378bdebd5d8787a83fbda5d9999cc9447209423e7f0218fe5eb240e6a32dc1b51d1cd53b4f8cd1f71574d935ac5e22e203dfe09cce17e9976a48416038e1263
49 lines
1.5 KiB
Bash
Executable File
49 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright (c) 2020 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
#
|
|
# Linter to check that commit messages have a new line before the body
|
|
# or no body at all
|
|
|
|
export LC_ALL=C
|
|
|
|
EXIT_CODE=0
|
|
|
|
while getopts "?" opt; do
|
|
case $opt in
|
|
?)
|
|
echo "Usage: $0 [N]"
|
|
echo " COMMIT_RANGE='<commit range>' $0"
|
|
echo " $0 -?"
|
|
echo "Checks unmerged commits, the previous N commits, or a commit range."
|
|
echo "COMMIT_RANGE='47ba2c3...ee50c9e' $0"
|
|
exit ${EXIT_CODE}
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ -z "${COMMIT_RANGE}" ]; then
|
|
if [ -n "$1" ]; then
|
|
COMMIT_RANGE="HEAD~$1...HEAD"
|
|
else
|
|
# This assumes that the target branch of the pull request will be develop
|
|
MERGE_BASE=$(git merge-base HEAD develop)
|
|
COMMIT_RANGE="$MERGE_BASE..HEAD"
|
|
fi
|
|
fi
|
|
|
|
while IFS= read -r commit_hash || [[ -n "$commit_hash" ]]; do
|
|
n_line=0
|
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
|
n_line=$((n_line+1))
|
|
length=${#line}
|
|
if [ $n_line -eq 2 ] && [ $length -ne 0 ]; then
|
|
echo "The subject line of commit hash ${commit_hash} is followed by a non-empty line. Subject lines should always be followed by a blank line."
|
|
EXIT_CODE=1
|
|
fi
|
|
done < <(git log --format=%B -n 1 "$commit_hash")
|
|
done < <(git log "${COMMIT_RANGE}" --format=%H)
|
|
|
|
exit ${EXIT_CODE}
|