fix(git): show a clean message when a directory is not a repository - #19
Merged
Conversation
Repository::discover failing with NotFound+Repository is the only error
whose libgit2 class/code tail ('; class=Repository (6); code=NotFound
(-3)') adds nothing the user can act on — the path is already in the
message prefix. A shared format_discover_error helper strips that tail
only for this class/code pair; all other errors (permission, corruption,
auth, …) keep the full diagnostic so clone-failure and other rich
git2::Error fields remain visible, preserving the decision in bce0239.
Both discover call sites — with_repo in diff_load and the commit-log
worker thread in commit_log_fetch — now route through the helper so the
status bar shows the same wording either way.
The notice row also stopped showing the repo path while a persistent
git error was up: notice_or_candidates replaced the entire repo header.
A non-repository directory is a persistent state, so the path was
permanently hidden. The notice now renders alongside the path on the
same line — path in gray bold, notice in red bold — and when the two do
not fit the path is kept and the notice is truncated with an ellipsis.
No new row is added, so open PTY panes are not resized.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
저장소가 아닌 디렉터리를 열었을 때 상태바가 보여주던 두 가지 문제를 함께 고칩니다. 하나만 고치면 나머지가 회귀하므로 한 커밋에 담았습니다.
1. libgit2 내부 진단이 그대로 노출됐다
git20.21의Display는 message 뒤에; class=…; code=…를 붙입니다. 사용자가 할 수 있는 일이 없고, 경로는 이미 앞부분에 있습니다.format_discover_error가ErrorClass::Repository+ErrorCode::NotFound조합에서만message()를 쓰고, 나머지(권한, 손상, 인증 등)는to_string()을 그대로 유지합니다.bce0239가 clone 실패에서 git의 진단을 살리기로 한 결정을 뒤집지 않기 위한 것으로, 문자열 매칭이 아니라 class/code로 갈랐습니다.discover호출부 두 곳(diff_load::with_repo,commit_log_fetch의 워커 스레드)이 같은 헬퍼를 거치므로 어느 경로로 실패해도 문구가 같습니다. 이전에는 서로 달랐습니다.2. 에러가 떠 있는 동안 현재 경로가 화면에서 사라졌다
notice_or_candidates가 repo 헤더를 통째로 대체했습니다. 저장소가 아닌 디렉터리는 사용자가 다른 경로를 열기 전까지 유지되는 상태라, 경로가 영구적으로 가려졌습니다.이제 경로(회색 굵게)와 notice(빨강 굵게)가 한 줄에 함께 렌더됩니다. 행을 새로 만들지 않았습니다 — 행이 생기고 사라지면 열려 있는 모든 PTY가 리사이즈되기 때문입니다(
recovery_chip주석의 근거와 동일).폭이 모자라면 경로를 남기고 notice를
…로 자릅니다. 남은 자리가 한 칸뿐이어도…는 남겨서, 잘렸다는 사실이 보이게 했습니다 —candidate_line의+N more와 같은 원칙입니다.검증
format_discover_error단위 테스트: NotFound/Repository에서 class·code 제거, 경로 보존, 다른 class는 전체 진단 유지.…유지, 자동완성 후보·헤더 폴백 무회귀.cargo fmt --all --check,cargo clippy --all-targets --all-features -- -D warnings,cargo test(1546 passed / 0 failed) 통과.