mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 21:24:59 +00:00
Open In Fleet
This commit is contained in:
parent
91bc1ee8ab
commit
cde5fc8f73
11 changed files with 149 additions and 59 deletions
|
@ -33,6 +33,13 @@ namespace SourceGit.Native
|
|||
if (File.Exists("/usr/share/code/code")) return "/usr/share/code/code";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
var path = "~/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet";
|
||||
if (File.Exists(path)) return path;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,16 @@ namespace SourceGit.Native
|
|||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
if (File.Exists("/Applications/Fleet.app/Contents/MacOS/Fleet"))
|
||||
{
|
||||
return "/Applications/Fleet.app/Contents/MacOS/Fleet";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,8 @@ using System.Diagnostics;
|
|||
|
||||
using Avalonia;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace SourceGit.Native
|
||||
{
|
||||
public static class OS
|
||||
|
@ -13,6 +15,7 @@ namespace SourceGit.Native
|
|||
|
||||
string FindGitExecutable();
|
||||
string FindVSCode();
|
||||
string FindFleet();
|
||||
|
||||
void OpenTerminal(string workdir);
|
||||
void OpenInFileManager(string path, bool select);
|
||||
|
@ -20,39 +23,36 @@ namespace SourceGit.Native
|
|||
void OpenWithDefaultEditor(string file);
|
||||
}
|
||||
|
||||
public static string GitInstallPath
|
||||
public static string GitInstallPath { get; set; }
|
||||
|
||||
public static string VSCodeExecutableFile { get; set; }
|
||||
|
||||
public static string FleetExecutableFile { get; set; }
|
||||
|
||||
public enum Platforms
|
||||
{
|
||||
get;
|
||||
set;
|
||||
Unknown = 0,
|
||||
Windows = 1,
|
||||
MacOS = 2,
|
||||
Linux
|
||||
}
|
||||
|
||||
public static string VSCodeExecutableFile
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public static Platforms Platform => OperatingSystem.IsWindows() ? Platforms.Windows : OperatingSystem.IsMacOS() ? Platforms.MacOS : OperatingSystem.IsLinux() ? Platforms.Linux : Platforms.Unknown;
|
||||
|
||||
static OS()
|
||||
{
|
||||
if (OperatingSystem.IsMacOS())
|
||||
_backend = Platform switch
|
||||
{
|
||||
_backend = new MacOS();
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
}
|
||||
else if (OperatingSystem.IsWindows())
|
||||
{
|
||||
_backend = new Windows();
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
}
|
||||
else if (OperatingSystem.IsLinux())
|
||||
{
|
||||
_backend = new Linux();
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Platform unsupported!!!");
|
||||
}
|
||||
#pragma warning disable CA1416
|
||||
Platforms.Windows => new Windows(),
|
||||
Platforms.MacOS => new MacOS(),
|
||||
Platforms.Linux => new Linux(),
|
||||
#pragma warning restore CA1416
|
||||
_ => throw new Exception("Platform unsupported!!!")
|
||||
};
|
||||
|
||||
VSCodeExecutableFile = _backend.FindVSCode();
|
||||
FleetExecutableFile = _backend.FindFleet();
|
||||
}
|
||||
|
||||
public static void SetupApp(AppBuilder builder)
|
||||
|
@ -95,13 +95,24 @@ namespace SourceGit.Native
|
|||
|
||||
Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
WorkingDirectory = repo,
|
||||
FileName = VSCodeExecutableFile,
|
||||
Arguments = $"\"{repo}\"",
|
||||
UseShellExecute = false,
|
||||
WorkingDirectory = repo, FileName = VSCodeExecutableFile, Arguments = $"\"{repo}\"", UseShellExecute = false,
|
||||
});
|
||||
}
|
||||
|
||||
private static readonly IBackend _backend = null;
|
||||
|
||||
public static void OpenInFleet(string repo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(FleetExecutableFile))
|
||||
{
|
||||
App.RaiseException(repo, "Fleet can NOT be found in your system!!!");
|
||||
return;
|
||||
}
|
||||
|
||||
Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
WorkingDirectory = repo, FileName = FleetExecutableFile, Arguments = $"\"{repo}\"", UseShellExecute = false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -103,34 +103,15 @@ namespace SourceGit.Native
|
|||
|
||||
public string FindVSCode()
|
||||
{
|
||||
var root = Microsoft.Win32.RegistryKey.OpenBaseKey(
|
||||
Microsoft.Win32.RegistryHive.LocalMachine,
|
||||
Environment.Is64BitOperatingSystem ? Microsoft.Win32.RegistryView.Registry64 : Microsoft.Win32.RegistryView.Registry32);
|
||||
|
||||
var vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1");
|
||||
if (vscode != null)
|
||||
{
|
||||
return vscode.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1");
|
||||
if (vscode != null)
|
||||
{
|
||||
return vscode.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1");
|
||||
if (vscode != null)
|
||||
{
|
||||
return vscode.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1");
|
||||
if (vscode != null)
|
||||
{
|
||||
return vscode.GetValue("DisplayIcon") as string;
|
||||
}
|
||||
|
||||
var vscodePath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe");
|
||||
if (File.Exists(vscodePath)) return vscodePath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string FindFleet()
|
||||
{
|
||||
var vscodePath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\AppData\\Local\\Programs\\Fleet\\Fleet.exe");
|
||||
if (File.Exists(vscodePath)) return vscodePath;
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue