Repository navigation
fix(dg): repo view says plainly why the security policy wasn't checked - #675
Conversation
Without git-remote-dash, `dg repo view` printed git's raw fetch error on stderr. It now reports "Security policy: not checked (…)" with a next step (install the helper, then clone), and keeps the raw cause in --json as securityPolicyError beside securityPolicyNote. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 44 minutes. View limit details
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. |
PastaPastaPasta
left a comment
There was a problem hiding this comment.
Verdict: approve
I read the diff at d73a2f9 against master and the code around it. I did not build or run anything locally. CI is the gate for that, and when I checked, rust build + test, the Windows check and the arm/x86 builds were still pending.
What I checked
- Helper installed but the fetch fails for another reason. This is handled correctly.
helper_missing = trueonly comes from the!helper_installed()branch, before any fetch. EveryErrfromsecurity_policy_fetchedgoes tolookup_failed(handle, false, …), so the note says "the default branch couldn't be fetched" and never says the helper is missing. Network errors, a non-plain default branch, scratch-repo errors and a non-executable helper file all get the generic note, with the raw cause insecurityPolicyError. git --exec-pathfailing. This is handled. TheErris ignored and only PATH is searched.gitruns with cwd.and needs no repository. If git itself is missing, the fetch would have failed anyway, and the generic note applies.- Windows.
EXE_SUFFIXgivesgit-remote-dash.exe, which matches what the release ships.split_pathshandles Windows PATH quoting. Git for Windows prints exec-path with forward slashes (C:/Program Files/Git/mingw64/libexec/git-core), andPathBuf::joinaccepts that. See nit 1. - JSON compatibility. Both new keys are additive and nullable. The schema keeps
additionalProperties: true, andgenerate.pyand the generated schema agree. No code in the repo reads therepo viewJSON key set strictly.securityPolicyNoteis also filled in the existing "too large" case (error is null there), which fits its schema description. --jsonstays on stdout. It does, and it is better than before. The oldeprintln!("note: … {e:#}")went to stderr even under--json, and it has been removed. Under--jsonthe remaining stderr line ("Fetching the default branch…") is already suppressed. The note and the next step now print only in the human closure, on stdout.
Non-blocking nits
crates/dg/src/repo.rs,helper_installed: on Windows, Git for Windows can also run an extensionless shebang script namedgit-remote-dash(and.cmdshims, via PATHEXT). A user with such a wrapper would be told the helper "isn't installed". That user runs a non-release setup, so this is low priority. Checking the bare name as well on Windows would close the gap.crates/dg/src/repo.rs,security_policy: the in-clone path (Some(found)fromsecurity_policy_in(&cwd, …)) also maps anErrto "the default branch couldn't be fetched", with the advice "dg repo clone …, then rundg repo viewin the clone". The user is already in that clone, and nothing was fetched. This is rare (git ls-treefailing on an objecthas_objectjust found), but the wording is wrong there.- The unit test covers
lookup_failedbut nothelper_installed. A small test that sets PATH to a temp dir with and without agit-remote-dash{EXE_SUFFIX}file would pin it down, though changing env in tests needs care with parallel runs.
🤖 Posted autonomously by Claude (claude-opus-5-5) on behalf of pasta.
Problem
When
git-remote-dashisn't installed,dg repo viewprints git's raw fetch error, which tells a new user nothing:Fix
repo viewnow checks for the helper (on PATH and ingit --exec-path) before fetching. If the policy look fails, it reports that in plain words and says what to do next:The raw cause moves to
--json, assecurityPolicyError, next to the plainsecurityPolicyNote:Both runs used real testnet, with binaries built from master (before) and from this branch (after), and a PATH that has no
git-remote-dash. The schema (docs/schemas/dg/repo-view.schema.json) is regenerated. A unit test covers the plain note and the next step for a missing helper and for a failed fetch.🤖 Generated with Claude Code