Skip to content

refactor: pre-push-hook.sh potential regression#7264

Merged
PastaPastaPasta merged 1 commit into
dashpay:developfrom
d0wn3d:patch-1
May 12, 2026
Merged

refactor: pre-push-hook.sh potential regression#7264
PastaPastaPasta merged 1 commit into
dashpay:developfrom
d0wn3d:patch-1

Conversation

@d0wn3d
Copy link
Copy Markdown

@d0wn3d d0wn3d commented Apr 2, 2026

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.

  • 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)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

@d0wn3d d0wn3d changed the title refactor: fix a potential regression refactor: pre-push-hook.sh potential regression Apr 2, 2026
@thepastaclaw
Copy link
Copy Markdown

thepastaclaw commented Apr 2, 2026

✅ Review complete (commit 3b99477)

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

Walkthrough

The pre-push hook's stdin parsing was changed from reading a single unstructured line and using positional parameters to reading four tab-delimited fields into named variables: local_ref, local_oid, remote_ref, and remote_oid. The branch check now compares remote_ref to refs/heads/master. When verifying signed commits, the script passes local_oid to verify-commits.py and, on failure, reruns verify-commits.py with the same local_oid. A shellcheck suppression was added for the unused local_ref variable.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor: pre-push-hook.sh potential regression' clearly identifies the main change—fixing a regression in the pre-push hook script's input parsing—and is concise and specific.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly explains the bug (quoted $LINE causing empty $3/$4), the problem with the prior workaround (ShellCheck SC2086), and the solution (using read for proper field parsing).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

The fix is both ShellCheck-compliant and functionally correct.
Copy link
Copy Markdown

@thepastaclaw thepastaclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Clean fix replacing fragile set -- A "$LINE" word-splitting with read -r named variables. The old code relied on positional parameters after set --, which is brittle when stdin lines contain unexpected whitespace or special characters. The new code uses read -r local_ref local_oid remote_ref remote_oid which directly maps to git's pre-push stdin format. Also fixes the error-path call to verify-commits.py which was missing the $local_oid argument. No issues found.

Reviewed commit: 3b99477

Copy link
Copy Markdown

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but we inherited this code from bitcoin so you probably want to submit your fix there too.

utACK 3b99477

Copy link
Copy Markdown

@thepastaclaw thepastaclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

PR correctly fixes a regression in contrib/verify-commits/pre-push-hook.sh where the previous set -- A "$LINE" form collapsed git's tab-delimited pre-push line into a single argument, making the refs/heads/master check always fail and silently skipping signature verification. The replacement with read -r local_ref local_oid remote_ref remote_oid matches git's documented pre-push stdin format and is ShellCheck-clean (the SC2034 suppression for unused local_ref/remote_oid is justified). Both agents and CodeRabbit reported no remaining defects at HEAD 3b99477.

Reviewed commit: 3b99477

Fresh dispatcher run for this queue item. A same-SHA review already existed, so this records the fresh verification without duplicating inline threads.

Code Review

Reviewed commit: 3b99477

@PastaPastaPasta PastaPastaPasta merged commit ee16b8d into dashpay:develop May 12, 2026
46 of 50 checks passed
@UdjinM6 UdjinM6 added this to the 24 milestone May 12, 2026
@d0wn3d d0wn3d deleted the patch-1 branch May 13, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants