refactor(git-error): drop locale-specific not-a-repo patterns
Child processes now have LANG/LC_ALL pinned to C.UTF-8 on every platform, so git stderr is always English when it leaks past the typed not_a_git_repository preflight. The 8 non-English regex fallbacks were dead code; keep only the English pattern as a belt-and-suspenders fallback for un-preflighted commands.
This commit is contained in:
@@ -1,29 +1,16 @@
|
|||||||
/**
|
/**
|
||||||
* Locale-independent patterns that identify a "not a git repository" error
|
* Fallback pattern that identifies a "not a git repository" error from the
|
||||||
* from the raw stderr of a failed git invocation.
|
* raw stderr of a failed git invocation.
|
||||||
*
|
*
|
||||||
* Git translates its error messages via gettext based on the **system**
|
* The primary detection path is the typed `not_a_git_repository` error code
|
||||||
* LC_MESSAGES locale, which may differ from the user's browser locale.
|
* returned by backend commands wrapped with a filesystem preflight check
|
||||||
* Detection therefore needs patterns for every language git might emit on
|
* (see `src-tauri/src/git_repo.rs::ensure_git_repo`). This pattern only
|
||||||
* the server, not just the one the UI is localized into.
|
* applies when an un-preflighted command leaks raw stderr to the client.
|
||||||
*
|
*
|
||||||
* These patterns are a belt-and-suspenders fallback. The primary detection
|
* Only the English form is needed: `src-tauri/src/process.rs` pins
|
||||||
* path is the typed `not_a_git_repository` error code returned by backend
|
* `LANG=C.UTF-8` / `LC_ALL=C.UTF-8` on every spawned child process, so git
|
||||||
* commands wrapped with a filesystem preflight check (see
|
* stderr is always English regardless of the system locale.
|
||||||
* `src-tauri/src/commands/folders.rs::ensure_git_repo`). Patterns only apply
|
|
||||||
* when an un-preflighted command leaks raw stderr to the client.
|
|
||||||
*
|
|
||||||
* Locales covered match git's own gettext translations. Arabic falls back to
|
|
||||||
* English in upstream git (no ar translation), so no separate pattern.
|
|
||||||
*/
|
*/
|
||||||
export const NOT_A_GIT_REPO_PATTERNS: readonly RegExp[] = [
|
export const NOT_A_GIT_REPO_PATTERNS: readonly RegExp[] = [
|
||||||
/not a git repository/i, // en
|
/not a git repository/i,
|
||||||
/不是\s*git\s*仓库/i, // zh-CN
|
|
||||||
/不是\s*git\s*儲存庫/i, // zh-TW
|
|
||||||
/git\s*リポジトリではありません/i, // ja
|
|
||||||
/git\s*저장소가\s*아닙니다/i, // ko
|
|
||||||
/kein\s*git[-\s]*repository/i, // de
|
|
||||||
/pas\s*(?:un|dans\s*un)\s*d[ée]p[oô]t\s*git/i, // fr
|
|
||||||
/no\s*es\s*un\s*repositorio\s*git/i, // es
|
|
||||||
/n[ãa]o\s*[ée]\s*um\s*reposit[oó]rio\s*git/i, // pt
|
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user