From 62452718b6fd86c132bc48a3aa7040cf9e02c92e Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 10 Mar 2025 18:36:57 +0800 Subject: [PATCH] fix: Force English locale in branch query command. --- src/Commands/Command.cs | 8 ++++++-- src/Commands/ExecuteCustomAction.cs | 10 ++++++++-- src/Commands/QueryBranches.cs | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index 3f61de174..f08965262 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -37,6 +37,7 @@ public enum EditorType public string Args { get; set; } = string.Empty; public bool RaiseError { get; set; } = true; public bool TraitErrorAsOutput { get; set; } = false; + protected bool ForceEnglishLocale { get; set; } = false; public bool Exec() { @@ -193,8 +194,11 @@ private ProcessStartInfo CreateGitStartInfo() start.Environment.Add("GIT_SSH_COMMAND", $"ssh -i '{SSHKey}'"); // Force using en_US.UTF-8 locale to avoid GCM crash - if (OperatingSystem.IsLinux()) - start.Environment.Add("LANG", "en_US.UTF-8"); + if (ForceEnglishLocale || OperatingSystem.IsLinux()) + { + start.Environment.Add("LANG", "C"); + start.Environment.Add("LC_ALL", "C"); + } // Fix macOS `PATH` env if (OperatingSystem.IsMacOS() && !string.IsNullOrEmpty(Native.OS.CustomPathEnv)) diff --git a/src/Commands/ExecuteCustomAction.cs b/src/Commands/ExecuteCustomAction.cs index 7775da344..e343700f1 100644 --- a/src/Commands/ExecuteCustomAction.cs +++ b/src/Commands/ExecuteCustomAction.cs @@ -19,7 +19,10 @@ public static void Run(string repo, string file, string args) // Force using en_US.UTF-8 locale to avoid GCM crash if (OperatingSystem.IsLinux()) - start.Environment.Add("LANG", "en_US.UTF-8"); + { + start.Environment.Add("LANG", "C"); + start.Environment.Add("LC_ALL", "C"); + } // Fix macOS `PATH` env if (OperatingSystem.IsMacOS() && !string.IsNullOrEmpty(Native.OS.CustomPathEnv)) @@ -50,7 +53,10 @@ public static void RunAndWait(string repo, string file, string args, Action