-
Notifications
You must be signed in to change notification settings - Fork 5.7k
script, ci: add scripted diff checks #1900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jonatack
wants to merge
3
commits into
bitcoin:master
Choose a base branch
from
jonatack:2025-07-scripted-diff-checks
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
# Copyright (c) 2009-present 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 | ||
|
||
if ! sed --help 2>&1 | grep -q 'GNU'; then | ||
echo "Error: the installed sed package is not compatible. Please make sure you have GNU sed installed in your system."; | ||
exit 1; | ||
fi | ||
|
||
if ! grep --help 2>&1 | grep -q 'GNU'; then | ||
echo "Error: the installed grep package is not compatible. Please make sure you have GNU grep installed in your system."; | ||
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" >&2 | ||
echo "Failed" >&2 | ||
RET=1 | ||
else | ||
echo "Running script for: $commit" >&2 | ||
echo "$SCRIPT" >&2 | ||
(eval "$SCRIPT") | ||
git --no-pager diff --exit-code "$commit" && echo "OK" >&2 || (echo "Failed" >&2; 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" >&2 | ||
echo "Failed" >&2 | ||
RET=1 | ||
fi | ||
fi | ||
done | ||
git checkout --quiet "$PREV_BRANCH" 2>/dev/null || git checkout --quiet "$PREV_HEAD" | ||
exit $RET |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was gonna say, I’m pretty sure that it was 2016, but I see now that you are just testing the CI.
Sorry that I haven’t reviewed this yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! No worries, I'm not passing the commit range correctly yet, putting it back into draft.