mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-28 18:32:56 +02:00
test: Enable SC2086 shellcheck rule
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
# one. Any remaining diff signals an error.
|
||||
|
||||
export LC_ALL=C
|
||||
if test -z $1; then
|
||||
if test -z "$1"; then
|
||||
echo "Usage: $0 <commit>..."
|
||||
exit 1
|
||||
fi
|
||||
@@ -20,10 +20,10 @@ 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')"
|
||||
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"
|
||||
@@ -32,16 +32,16 @@ for commit in $(git rev-list --reverse $1); do
|
||||
echo "Running script for: $commit"
|
||||
echo "$SCRIPT"
|
||||
(eval "$SCRIPT")
|
||||
git --no-pager diff --exit-code $commit && echo "OK" || (echo "Failed"; false) || RET=1
|
||||
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
|
||||
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
|
||||
git checkout --quiet "$PREV_BRANCH" 2>/dev/null || git checkout --quiet "$PREV_HEAD"
|
||||
exit $RET
|
||||
|
@@ -82,6 +82,7 @@ if [ -z "$latest_squash" ]; then
|
||||
echo "ERROR: $DIR is not a subtree" >&2
|
||||
exit 2
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
set $latest_squash
|
||||
old=$1
|
||||
rev=$2
|
||||
@@ -92,6 +93,7 @@ if [ -z "$tree_actual" ]; then
|
||||
echo "FAIL: subtree directory $DIR not found in $COMMIT" >&2
|
||||
exit 1
|
||||
fi
|
||||
# shellcheck disable=SC2086
|
||||
set $tree_actual
|
||||
tree_actual_type=$2
|
||||
tree_actual_tree=$3
|
||||
@@ -102,23 +104,23 @@ if [ "d$tree_actual_type" != "dtree" ]; then
|
||||
fi
|
||||
|
||||
# get the tree at the time of the last subtree update
|
||||
tree_commit=$(git show -s --format="%T" $old)
|
||||
tree_commit=$(git show -s --format="%T" "$old")
|
||||
echo "$DIR in $COMMIT was last updated in commit $old (tree $tree_commit)"
|
||||
|
||||
# ... and compare the actual tree with it
|
||||
if [ "$tree_actual_tree" != "$tree_commit" ]; then
|
||||
git diff $tree_commit $tree_actual_tree >&2
|
||||
git diff "$tree_commit" "$tree_actual_tree" >&2
|
||||
echo "FAIL: subtree directory was touched without subtree merge" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$check_remote" != "0" ]; then
|
||||
# get the tree in the subtree commit referred to
|
||||
if [ "d$(git cat-file -t $rev 2>/dev/null)" != dcommit ]; then
|
||||
if [ "d$(git cat-file -t "$rev" 2>/dev/null)" != dcommit ]; then
|
||||
echo "subtree commit $rev unavailable: cannot compare. Did you add and fetch the remote?" >&2
|
||||
exit 1
|
||||
fi
|
||||
tree_subtree=$(git show -s --format="%T" $rev)
|
||||
tree_subtree=$(git show -s --format="%T" "$rev")
|
||||
echo "$DIR in $COMMIT was last updated to upstream commit $rev (tree $tree_subtree)"
|
||||
|
||||
# ... and compare the actual tree with it
|
||||
|
@@ -3,5 +3,5 @@
|
||||
export LC_ALL=C
|
||||
|
||||
set -e
|
||||
cd "$(dirname $0)/../.."
|
||||
cd "$(dirname "$0")/../.."
|
||||
test/lint/lint-files.py
|
||||
|
@@ -38,7 +38,7 @@ while IFS= read -r commit_hash || [[ -n "$commit_hash" ]]; do
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
n_line=$((n_line+1))
|
||||
length=${#line}
|
||||
if [ $n_line -eq 2 ] && [ $length -ne 0 ]; then
|
||||
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
|
||||
|
@@ -12,7 +12,7 @@ export LC_ALL=C
|
||||
IGNORE_REGEXP="/(leveldb|secp256k1|minisketch|univalue|crc32c)/"
|
||||
|
||||
# cd to root folder of git repo for git ls-files to work properly
|
||||
cd "$(dirname $0)/../.." || exit 1
|
||||
cd "$(dirname "$0")/../.." || exit 1
|
||||
|
||||
filter_suffix() {
|
||||
git ls-files | grep -E "^src/.*\.${1}"'$' | grep -Ev "${IGNORE_REGEXP}"
|
||||
|
@@ -11,7 +11,6 @@ export LC_ALL=C
|
||||
# Disabled warnings:
|
||||
disabled=(
|
||||
SC2046 # Quote this to prevent word splitting.
|
||||
SC2086 # Double quote to prevent globbing and word splitting.
|
||||
SC2162 # read without -r will mangle backslashes.
|
||||
)
|
||||
|
||||
@@ -24,8 +23,9 @@ fi
|
||||
|
||||
SHELLCHECK_CMD=(shellcheck --external-sources --check-sourced)
|
||||
EXCLUDE="--exclude=$(IFS=','; echo "${disabled[*]}")"
|
||||
SOURCED_FILES=$(git ls-files | xargs gawk '/^# shellcheck shell=/ {print FILENAME} {nextfile}') # Check shellcheck directive used for sourced files
|
||||
if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" $SOURCED_FILES $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|minisketch|univalue)/'); then
|
||||
# Check shellcheck directive used for sourced files
|
||||
mapfile -t SOURCED_FILES < <(git ls-files | xargs gawk '/^# shellcheck shell=/ {print FILENAME} {nextfile}')
|
||||
if ! "${SHELLCHECK_CMD[@]}" "$EXCLUDE" "${SOURCED_FILES[@]}" $(git ls-files -- '*.sh' | grep -vE 'src/(leveldb|secp256k1|minisketch|univalue)/'); then
|
||||
EXIT_CODE=1
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user