mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 05:35:00 +00:00
refactor: using custom PATH
instead of reading it from zsh
(#581)
* run `echo $PATH > ~/Library/Application\ Support/SourceGit/PATH` to generate to custom PATH file for SourceGit
This commit is contained in:
parent
188bf02349
commit
67b6a6d9d5
4 changed files with 9 additions and 25 deletions
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Text;
|
||||
|
||||
using Avalonia;
|
||||
|
||||
|
@ -19,30 +18,9 @@ namespace SourceGit.Native
|
|||
DisableDefaultApplicationMenuItems = true,
|
||||
});
|
||||
|
||||
{
|
||||
var startInfo = new ProcessStartInfo();
|
||||
startInfo.FileName = "zsh";
|
||||
startInfo.Arguments = "--login -c \"echo $PATH\"";
|
||||
startInfo.UseShellExecute = false;
|
||||
startInfo.CreateNoWindow = true;
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.StandardOutputEncoding = Encoding.UTF8;
|
||||
|
||||
try
|
||||
{
|
||||
var proc = new Process() { StartInfo = startInfo };
|
||||
proc.Start();
|
||||
var pathData = proc.StandardOutput.ReadToEnd();
|
||||
proc.WaitForExit();
|
||||
if (proc.ExitCode == 0)
|
||||
Environment.SetEnvironmentVariable("PATH", pathData);
|
||||
proc.Close();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Ignore error.
|
||||
}
|
||||
}
|
||||
var customPathFile = Path.Combine(OS.DataDir, "PATH");
|
||||
if (File.Exists(customPathFile))
|
||||
OS.CustomPathEnv = File.ReadAllText(customPathFile).Trim();
|
||||
}
|
||||
|
||||
public string FindGitExecutable()
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace SourceGit.Native
|
|||
public static string GitExecutable { get; set; } = string.Empty;
|
||||
public static string ShellOrTerminal { get; set; } = string.Empty;
|
||||
public static List<Models.ExternalTool> ExternalTools { get; set; } = [];
|
||||
public static string CustomPathEnv { get; set; } = string.Empty;
|
||||
|
||||
static OS()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue