mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Merge #12098: [scripts] lint-whitespace: add param to check last N commits
8dbf740f8
[scripts] lint-whitespace: check last N commits or unstaged changes (Sjors Provoost)
Pull request description:
E.g. before you push three commits to Github and upset Travis, check if you didn't make any whitespace mistakes:
```sh
contrib/devtools/lint-whitespace.sh 3
```
This is slightly more convenient than doing:
```sh
TRAVIS_COMMIT_RANGE=HEAD~3...HEAD contrib/devtools/lint-whitespace.sh
```
Tree-SHA512: 5d9c1ae978ccbe59477e8cf53391e9bd697d2da87f417a2519264af560d4768138e0b2d320dd497a1f1e704e18ab279d724f523b57c17a80ccd753133a5445bf
This commit is contained in:
parent
a88ad9384f
commit
e9b42fd5c3
@ -7,12 +7,26 @@
|
|||||||
# Check for new lines in diff that introduce trailing whitespace.
|
# Check for new lines in diff that introduce trailing whitespace.
|
||||||
|
|
||||||
# We can't run this check unless we know the commit range for the PR.
|
# We can't run this check unless we know the commit range for the PR.
|
||||||
if [ -z "${COMMIT_RANGE}" ]; then
|
|
||||||
echo "Cannot run lint-whitespace.sh without commit range. To run locally, use:"
|
while getopts "?" opt; do
|
||||||
echo "COMMIT_RANGE='<commit range>' .lint-whitespace.sh"
|
case $opt in
|
||||||
echo "For example:"
|
?)
|
||||||
|
echo "Usage: .lint-whitespace.sh [N]"
|
||||||
|
echo " COMMIT_RANGE='<commit range>' .lint-whitespace.sh"
|
||||||
|
echo " .lint-whitespace.sh -?"
|
||||||
|
echo "Checks unstaged changes, the previous N commits, or a commit range."
|
||||||
echo "COMMIT_RANGE='47ba2c3...ee50c9e' .lint-whitespace.sh"
|
echo "COMMIT_RANGE='47ba2c3...ee50c9e' .lint-whitespace.sh"
|
||||||
exit 1
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "${COMMIT_RANGE}" ]; then
|
||||||
|
if [ "$1" ]; then
|
||||||
|
COMMIT_RANGE="HEAD~$1...HEAD"
|
||||||
|
else
|
||||||
|
COMMIT_RANGE="HEAD"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
showdiff() {
|
showdiff() {
|
||||||
|
Loading…
Reference in New Issue
Block a user