feat(git): enhance error reporting and auth robustness

The commit enhances Git operation reliability by improving how authentication errors are detected and displayed to the user. It standardizes Git output language across different locales and introduces a mechanism to summarize complex raw Git stderr messages, ensuring users receive clear feedback when cloning or interacting with repositories that fail due to credentials.

- Standardize git command output using LC_ALL=C for consistent English messaging.
- Implement error summarization logic to extract the most relevant message from raw Git stderr.
- Update credential dialogs to display summarized and improved authentication failure details.
This commit is contained in:
2026-07-19 16:41:21 +02:00
parent 35310bec6d
commit 2bd60f0e5b
4 changed files with 33 additions and 4 deletions
+7
View File
@@ -300,6 +300,10 @@ static CANCELLABLE_GIT_OUTPUT_COUNTER: AtomicU64 = AtomicU64::new(0);
fn git_command() -> Command {
let mut command = Command::new("git");
// Force English output regardless of the system locale, so is_auth_error()
// and other message heuristics keep working (e.g. German git prints
// "Authentifizierung fehlgeschlagen" instead of "Authentication failed").
command.env("LC_ALL", "C");
#[cfg(windows)]
command.creation_flags(CREATE_NO_WINDOW);
command
@@ -4484,6 +4488,9 @@ fn is_auth_error(details: &str) -> bool {
|| d.contains(" 401")
|| d.contains("authorization failed")
|| d.contains("authentication required")
// Server-side message (e.g. Gitea/Forgejo: "remote: Failed to
// authenticate user"), independent of the local git locale.
|| d.contains("failed to authenticate")
}
// Windows' CreateProcess rejects command lines longer than ~32K chars with