diff options
author | Sjors Provoost <sjors@sprovoost.nl> | 2018-01-08 12:10:07 +0100 |
---|---|---|
committer | Sjors Provoost <sjors@sprovoost.nl> | 2018-01-08 12:10:07 +0100 |
commit | 8dbf740f8055b095f172772d457acca56115d9d1 (patch) | |
tree | 9230535b8e700d2af02275e85a5e356541171a8f /contrib | |
parent | 56910285fa4a7a0f3b931e7613b9691cee9c13ff (diff) |
[scripts] lint-whitespace: check last N commits or unstaged changes
Get usage instructions:
.lint-whitespace.sh -?
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/devtools/lint-whitespace.sh | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/contrib/devtools/lint-whitespace.sh b/contrib/devtools/lint-whitespace.sh index 989923f31a..8696903e68 100755 --- a/contrib/devtools/lint-whitespace.sh +++ b/contrib/devtools/lint-whitespace.sh @@ -7,12 +7,26 @@ # 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. + +while getopts "?" opt; do + case $opt in + ?) + echo "Usage: .lint-whitespace.sh [N]" + echo " TRAVIS_COMMIT_RANGE='<commit range>' .lint-whitespace.sh" + echo " .lint-whitespace.sh -?" + echo "Checks unstaged changes, the previous N commits, or a commit range." + echo "TRAVIS_COMMIT_RANGE='47ba2c3...ee50c9e' .lint-whitespace.sh" + exit 0 + ;; + esac +done + if [ -z "${TRAVIS_COMMIT_RANGE}" ]; then - echo "Cannot run lint-whitespace.sh without commit range. To run locally, use:" - echo "TRAVIS_COMMIT_RANGE='<commit range>' .lint-whitespace.sh" - echo "For example:" - echo "TRAVIS_COMMIT_RANGE='47ba2c3...ee50c9e' .lint-whitespace.sh" - exit 1 + if [ "$1" ]; then + TRAVIS_COMMIT_RANGE="HEAD~$1...HEAD" + else + TRAVIS_COMMIT_RANGE="HEAD" + fi fi showdiff() { |