Skip to content

fix(scripts): surface git-diff failure in selfhost pre-deploy summary#7787

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:fix-predeploy-gitdiff-7775
Jul 21, 2026
Merged

fix(scripts): surface git-diff failure in selfhost pre-deploy summary#7787
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jaytbarimbao-collab:fix-predeploy-gitdiff-7775

Conversation

@jaytbarimbao-collab

Copy link
Copy Markdown
Contributor

Closes #7775

scripts/selfhost-pre-deploy-summary.sh scanned for historically-sensitive deploy paths by piping git diff --name-only "$range" into a loop via a process substitution (done < <(git diff ...)). A process substitution's exit status is invisible to set -euo pipefail, so if that git diff failed (bad ref, shallow clone, detached history), the loop simply saw zero lines and the script printed "no historically-sensitive paths touched" — a false all-clear on what is meant to be a deploy-safety advisory.

Fix: capture the diff through a checked command substitution and error out loudly if it fails, instead of silently proceeding:

if ! diff_output="$(git diff --name-only "$range")"; then
  echo "error: 'git diff --name-only $range' failed; cannot assess historically-sensitive paths" >&2
  exit 1
fi
while IFS= read -r file; do
  ...
done <<< "$diff_output"

The success path is unchanged (all existing behavior tests still pass).

Test: added a regression test to test/unit/selfhost-pre-deploy-summary-script.test.ts that shadows git with a fake failing only git diff --name-only (delegating fetch and git diff --stat to real git), then asserts the script exits non-zero with the "cannot assess historically-sensitive paths" error rather than the false all-clear. scripts/** is outside the Codecov coverage.include, so no patch-coverage gate applies.

The sensitive-path scan read `git diff --name-only` via a process
substitution (`done < <(git diff ...)`), whose exit status is invisible
to `set -euo pipefail`. A diff failure (bad ref, shallow clone, detached
history) left the loop with zero lines, so the script reported "no
historically-sensitive paths touched" -- a false all-clear on a
deploy-safety advisory. Capture the diff via a checked command
substitution and error out loudly if it fails.

Closes JSONbored#7775
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.57%. Comparing base (0709850) to head (ccadf32).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7787   +/-   ##
=======================================
  Coverage   88.57%   88.57%           
=======================================
  Files         725      725           
  Lines       76410    76410           
  Branches    22762    22760    -2     
=======================================
  Hits        67683    67683           
  Misses       7681     7681           
  Partials     1046     1046           
Flag Coverage Δ
shard-1 55.40% <ø> (ø)
shard-2 52.57% <ø> (-0.01%) ⬇️
shard-3 47.38% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-21 13:00:16 UTC

2 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a narrow, correct fix for #7775: swapping `done < <(git diff ...)` for a checked command substitution (`diff_output="$(...)"`) closes the exact hole where a process-substitution failure was invisible to `set -euo pipefail`, previously producing a false 'no historically-sensitive paths touched' all-clear. The success path (`<<< "$diff_output"` replacing `< <(...)`) is behaviorally equivalent, and the added test genuinely shadows only `git diff --name-only` while delegating fetch and `git diff --stat` to real git, exercising the actual failure path rather than fabricating an unreachable state. Scope is tight and matches the linked issue.

Nits — 4 non-blocking
  • The inline comment block above the fix (scripts/selfhost-pre-deploy-summary.sh:118-122) duplicates most of the PR description almost verbatim — could be trimmed to a shorter pointer to selfhost-pre-deploy-summary.sh gives a false all-clear if its own git diff command fails #7775 to avoid comment bloat next to the existing large sensitive-paths comment block.
  • The fake git shim in the test (test/unit/selfhost-pre-deploy-summary-script.test.ts) hardcodes `$1`/`$2` positional checks for `diff --name-only`; if the script's flag order ever changes this test would silently stop exercising the failure path — a minor coupling worth a one-line comment noting the dependency.
  • Consider shortening the new script comment to one or two lines referencing selfhost-pre-deploy-summary.sh gives a false all-clear if its own git diff command fails #7775 instead of restating the full rationale already covered in the PR description.
  • Could add a similarly-checked substitution note/reference near `git rev-list --count` and `git diff --stat` calls if those are ever suspected of similar silent-failure risk, though that's out of scope for this PR.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7775
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 151 registered-repo PR(s), 73 merged, 16 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jaytbarimbao-collab; Gittensor profile; 151 PR(s), 16 issue(s).
Improvement ℹ️ Insufficient signal risk: clean · value: insufficient-signal
Linked issue satisfaction

Addressed
The diff replaces the unchecked process substitution with a checked command substitution that exits non-zero and prints an explicit error when git diff fails, exactly matching the requested fix pattern, and adds a regression test simulating the diff failure.

Review context
  • Author: jaytbarimbao-collab
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Rust
  • Official Gittensor activity: 151 PR(s), 16 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 07064df into JSONbored:main Jul 21, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

selfhost-pre-deploy-summary.sh gives a false all-clear if its own git diff command fails

1 participant