diff --git a/src/SourceGit/Native/Linux.cs b/src/SourceGit/Native/Linux.cs index a770abf5..6aa2b50d 100644 --- a/src/SourceGit/Native/Linux.cs +++ b/src/SourceGit/Native/Linux.cs @@ -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) { diff --git a/src/SourceGit/Native/MacOS.cs b/src/SourceGit/Native/MacOS.cs index b56ab1ff..d0586a12 100644 --- a/src/SourceGit/Native/MacOS.cs +++ b/src/SourceGit/Native/MacOS.cs @@ -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) { diff --git a/src/SourceGit/Native/OS.cs b/src/SourceGit/Native/OS.cs index 78f12972..7169d51f 100644 --- a/src/SourceGit/Native/OS.cs +++ b/src/SourceGit/Native/OS.cs @@ -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, + }); + } } } \ No newline at end of file diff --git a/src/SourceGit/Native/Windows.cs b/src/SourceGit/Native/Windows.cs index 14f04aec..b958acca 100644 --- a/src/SourceGit/Native/Windows.cs +++ b/src/SourceGit/Native/Windows.cs @@ -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; } diff --git a/src/SourceGit/Resources/ExternalToolIcons/fleet_icon.svg b/src/SourceGit/Resources/ExternalToolIcons/fleet_icon.svg new file mode 100644 index 00000000..3ab51b6e --- /dev/null +++ b/src/SourceGit/Resources/ExternalToolIcons/fleet_icon.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SourceGit/Resources/Locales.Designer.cs b/src/SourceGit/Resources/Locales.Designer.cs index ba492504..4419d3ef 100644 --- a/src/SourceGit/Resources/Locales.Designer.cs +++ b/src/SourceGit/Resources/Locales.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -2967,6 +2966,15 @@ namespace SourceGit.Resources { } } + /// + /// Looks up a localized string similar to Open In Fleet. + /// + public static string Text_Repository_Fleet { + get { + return ResourceManager.GetString("Text.Repository.Fleet", resourceCulture); + } + } + /// /// Looks up a localized string similar to LOCAL BRANCHES. /// diff --git a/src/SourceGit/Resources/Locales.en.resx b/src/SourceGit/Resources/Locales.en.resx index 2f9e7bdd..d1a51612 100644 --- a/src/SourceGit/Resources/Locales.en.resx +++ b/src/SourceGit/Resources/Locales.en.resx @@ -342,6 +342,9 @@ Open In Visual Studio Code + + Open In Fleet + Open In Git Bash diff --git a/src/SourceGit/Resources/Locales.resx b/src/SourceGit/Resources/Locales.resx index 8e06cd4d..22caa86b 100644 --- a/src/SourceGit/Resources/Locales.resx +++ b/src/SourceGit/Resources/Locales.resx @@ -342,6 +342,9 @@ Open In Visual Studio Code + + Open In Fleet + Open In Git Bash diff --git a/src/SourceGit/SourceGit.csproj b/src/SourceGit/SourceGit.csproj index 0edbbb2f..9dbaa5c5 100644 --- a/src/SourceGit/SourceGit.csproj +++ b/src/SourceGit/SourceGit.csproj @@ -44,6 +44,7 @@ + @@ -57,4 +58,8 @@ + + + + diff --git a/src/SourceGit/ViewModels/Repository.cs b/src/SourceGit/ViewModels/Repository.cs index ee684ee3..76444e6e 100644 --- a/src/SourceGit/ViewModels/Repository.cs +++ b/src/SourceGit/ViewModels/Repository.cs @@ -54,6 +54,12 @@ namespace SourceGit.ViewModels { get => !string.IsNullOrEmpty(Native.OS.VSCodeExecutableFile); } + + [JsonIgnore] + public bool IsFleetFound + { + get => !string.IsNullOrEmpty(Native.OS.FleetExecutableFile); + } [JsonIgnore] public Models.GitFlow GitFlow @@ -285,6 +291,11 @@ namespace SourceGit.ViewModels { Native.OS.OpenInVSCode(_fullpath); } + + public void OpenInFleet() + { + Native.OS.OpenInFleet(_fullpath); + } public void OpenInTerminal() { diff --git a/src/SourceGit/Views/Repository.axaml b/src/SourceGit/Views/Repository.axaml index 9759ba00..df765842 100644 --- a/src/SourceGit/Views/Repository.axaml +++ b/src/SourceGit/Views/Repository.axaml @@ -21,6 +21,7 @@ +