fix(git): surface non-git-repo as a typed error and align all panels via workspace state
Consolidate `.git` presence detection into a shared `git_repo` module used by both the workspace state watcher and the command preflight helper, replacing duplicated local definitions. Introduce `AppErrorCode::NotAGitRepository` (HTTP 422) and preflight eleven frontend-callable git commands (log, status, list-branches, diff, diff-with-branch, show-diff, show-file, push-info, list-remotes, list-all-branches, commit-branches) so non-git folders short-circuit with a structured error instead of leaking locale-dependent git stderr. Frontend `isNotAGitRepoError` checks the error code first and falls back to a multi-language regex list centralized in `src/i18n/git-error-patterns.ts`, covering the nine languages git actually translates into. Wire the git log panel to `workspaceState.isGitRepo` rather than a local cached flag, so running `git init` or deleting `.git` externally propagates through the watcher and refreshes the panel automatically.
This commit is contained in:
@@ -9,6 +9,7 @@ pub enum AppErrorCode {
|
||||
ConfigurationMissing,
|
||||
ConfigurationInvalid,
|
||||
NotFound,
|
||||
NotAGitRepository,
|
||||
AlreadyExists,
|
||||
PermissionDenied,
|
||||
DependencyMissing,
|
||||
@@ -65,6 +66,10 @@ impl AppCommandError {
|
||||
Self::new(AppErrorCode::NotFound, message)
|
||||
}
|
||||
|
||||
pub fn not_a_git_repository(message: impl Into<String>) -> Self {
|
||||
Self::new(AppErrorCode::NotAGitRepository, message)
|
||||
}
|
||||
|
||||
pub fn already_exists(message: impl Into<String>) -> Self {
|
||||
Self::new(AppErrorCode::AlreadyExists, message)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user