Skip to content

Commit ee16b8d

Browse files
Merge #7264: refactor: pre-push-hook.sh potential regression
3b99477 refactor: fix a potential regression (Antonio Moratti) Pull request description: ## Issue being fixed or feature implemented With set -- A "$LINE" (quoted), the entire input line becomes $2 as a single string, leaving $3 and $4 empty. Since empty $4 never equals "refs/heads/master", the hook always continues, and the commit-signing verification never executes in either repo. Using the unquoted form `set -- A $LINE` (no quotes), which relied on word-splitting to populate `$2`…`$5` correctly, trips **ShellCheck's SC2086** rule. ## What was done? Parse the fields directly with `read:` The fix is both ShellCheck-compliant and functionally correct. edit: Added `# shellcheck disable=SC2034` to bypass false positive `x not being used` warning. ## How Has This Been Tested? Not tested. ## Breaking Changes None. ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [X] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: LGTM but we inherited this code from [bitcoin](https://github.com/bitcoin/bitcoin) so you probably want to submit your fix there too. utACK 3b99477 Tree-SHA512: c7106542572f022e3d36b58ecbbde8c2f1d5499af3d2c2c38aeeaf445bd55cfdf8ffd12e9a2bc4a193213a5a1f769bd062d35fe9157ca024bb201ef095f46605
2 parents 080352e + 3b99477 commit ee16b8d

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

contrib/verify-commits/pre-push-hook.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ if ! [[ "$2" =~ ^(git@)?(www.)?github.com(:|/)dashpay/dash(.git)?$ ]]; then
88
exit 0
99
fi
1010

11-
while read LINE; do
12-
set -- A "$LINE"
13-
if [ "$4" != "refs/heads/master" ]; then
11+
# shellcheck disable=SC2034
12+
while read -r local_ref local_oid remote_ref remote_oid; do
13+
if [ "$remote_ref" != "refs/heads/master" ]; then
1414
continue
1515
fi
16-
if ! ./contrib/verify-commits/verify-commits.py "$3" > /dev/null 2>&1; then
16+
if ! ./contrib/verify-commits/verify-commits.py "$local_oid" > /dev/null 2>&1; then
1717
echo "ERROR: A commit is not signed, can't push"
18-
./contrib/verify-commits/verify-commits.py
18+
./contrib/verify-commits/verify-commits.py "$local_oid"
1919
exit 1
2020
fi
2121
done < /dev/stdin

0 commit comments

Comments
 (0)