Skip to content

Commit e50c33e

Browse files
committed
devtools: add script to verify scriptable changes
1 parent 4c92401 commit e50c33e

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ install:
4343
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get update; fi
4444
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES; fi
4545
before_script:
46+
- if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then contrib/devtools/commit-script-check.sh $TRAVIS_COMMIT_RANGE; fi
4647
- unset CC; unset CXX
4748
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-doc.py; fi
4849
- mkdir -p depends/SDKs depends/sdk-sources
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
# Copyright (c) 2017 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+
# This simple script checks for commits beginning with: scripted-diff:
7+
# If found, looks for a script between the lines -BEGIN VERIFY SCRIPT- and
8+
# -END VERIFY SCRIPT-. If no ending is found, it reads until the end of the
9+
# commit message.
10+
11+
# The resulting script should exactly transform the previous commit into the current
12+
# one. Any remaining diff signals an error.
13+
14+
if test "x$1" = "x"; then
15+
echo "Usage: $0 <commit>..."
16+
exit 1
17+
fi
18+
19+
RET=0
20+
PREV_BRANCH=`git name-rev --name-only HEAD`
21+
PREV_HEAD=`git rev-parse HEAD`
22+
for i in `git rev-list --reverse $1`; do
23+
git rev-list -n 1 --pretty="%s" $i | grep -q "^scripted-diff:" || continue
24+
git checkout --quiet $i^ || exit
25+
SCRIPT="`git rev-list --format=%b -n1 $i | sed '/^-BEGIN VERIFY SCRIPT-$/,/^-END VERIFY SCRIPT-$/{//!b};d'`"
26+
if test "x$SCRIPT" = "x"; then
27+
echo "Error: missing script for: $i"
28+
echo "Failed"
29+
RET=1
30+
else
31+
echo "Running script for: $i"
32+
echo "$SCRIPT"
33+
eval "$SCRIPT"
34+
git --no-pager diff --exit-code $i && echo "OK" || (echo "Failed"; false) || RET=1
35+
fi
36+
git reset --quiet --hard HEAD
37+
done
38+
git checkout --quiet $PREV_BRANCH 2>/dev/null || git checkout --quiet $PREV_HEAD
39+
exit $RET

0 commit comments

Comments
 (0)