mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
ffe950bbc7
1ac454a3844b9b8389de0f660fa9455c0efa7140 Enable ShellCheck rules (Hennadii Stepanov) Pull request description: Enable some simple ShellCheck rules. Note for reviewers: `bash` and `shellcheck` on macOS are different from ones on Ubuntu. For local tests the latest `shellcheck` version 0.6.0 should be used (see #15166). ACKs for top commit: practicalswift: utACK 1ac454a3844b9b8389de0f660fa9455c0efa7140 dongcarl: utACK 1ac454a fanquake: ACK 1ac454a3844b9b8389de0f660fa9455c0efa7140 Tree-SHA512: 8d0a3a5c09fe1a0c22120178f5e6b80f81f746f8c3356b7701ff301c117acb2edea8fe08f08fb54ed73f94b1617515fb239fa28e7ab4121f74872e6494b6f20e
48 lines
1.7 KiB
Bash
Executable File
48 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright (c) 2017 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
# This simple script checks for commits beginning with: scripted-diff:
|
|
# If found, looks for a script between the lines -BEGIN VERIFY SCRIPT- and
|
|
# -END VERIFY SCRIPT-. If no ending is found, it reads until the end of the
|
|
# commit message.
|
|
|
|
# The resulting script should exactly transform the previous commit into the current
|
|
# one. Any remaining diff signals an error.
|
|
|
|
export LC_ALL=C
|
|
if test -z "$1"; then
|
|
echo "Usage: $0 <commit>..."
|
|
exit 1
|
|
fi
|
|
|
|
RET=0
|
|
PREV_BRANCH=$(git name-rev --name-only HEAD)
|
|
PREV_HEAD=$(git rev-parse HEAD)
|
|
for commit in $(git rev-list --reverse $1); do
|
|
if git rev-list -n 1 --pretty="%s" $commit | grep -q "^scripted-diff:"; then
|
|
git checkout --quiet $commit^ || exit
|
|
SCRIPT="$(git rev-list --format=%b -n1 $commit | sed '/^-BEGIN VERIFY SCRIPT-$/,/^-END VERIFY SCRIPT-$/{//!b};d')"
|
|
if test -z "$SCRIPT"; then
|
|
echo "Error: missing script for: $commit"
|
|
echo "Failed"
|
|
RET=1
|
|
else
|
|
echo "Running script for: $commit"
|
|
echo "$SCRIPT"
|
|
(eval "$SCRIPT")
|
|
git --no-pager diff --exit-code $commit && echo "OK" || (echo "Failed"; false) || RET=1
|
|
fi
|
|
git reset --quiet --hard HEAD
|
|
else
|
|
if git rev-list "--format=%b" -n1 $commit | grep -q '^-\(BEGIN\|END\)[ a-zA-Z]*-$'; then
|
|
echo "Error: script block marker but no scripted-diff in title of commit $commit"
|
|
echo "Failed"
|
|
RET=1
|
|
fi
|
|
fi
|
|
done
|
|
git checkout --quiet $PREV_BRANCH 2>/dev/null || git checkout --quiet $PREV_HEAD
|
|
exit $RET
|