diff --git a/src/SourceGit/Native/Linux.cs b/src/SourceGit/Native/Linux.cs index a770abf56e..852eee4b7c 100644 --- a/src/SourceGit/Native/Linux.cs +++ b/src/SourceGit/Native/Linux.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.IO; using System.Runtime.Versioning; @@ -30,7 +31,15 @@ public string FindGitExecutable() public string FindVSCode() { - if (File.Exists("/usr/share/code/code")) return "/usr/share/code/code"; + var toolPath = "/usr/share/code/code"; + if (File.Exists(toolPath)) return toolPath; + return string.Empty; + } + + public string FindFleet() + { + var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet"; + if (File.Exists(toolPath)) return toolPath; return string.Empty; } diff --git a/src/SourceGit/Native/MacOS.cs b/src/SourceGit/Native/MacOS.cs index b56ab1ff17..006f7e8ebf 100644 --- a/src/SourceGit/Native/MacOS.cs +++ b/src/SourceGit/Native/MacOS.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; using System.IO; using System.Runtime.Versioning; using System.Text; @@ -27,11 +28,17 @@ public string FindGitExecutable() public string FindVSCode() { - if (File.Exists("/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code")) - { - return "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"; - } - + var toolPath = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"; + if (File.Exists(toolPath)) + return toolPath; + return string.Empty; + } + + public string FindFleet() + { + var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Applications/Fleet.app/Contents/MacOS/Fleet"; + if (File.Exists(toolPath)) + return toolPath; return string.Empty; } diff --git a/src/SourceGit/Native/OS.cs b/src/SourceGit/Native/OS.cs index 78f1297268..7169d51f9f 100644 --- a/src/SourceGit/Native/OS.cs +++ b/src/SourceGit/Native/OS.cs @@ -3,6 +3,8 @@ using Avalonia; +// ReSharper disable InconsistentNaming + namespace SourceGit.Native { public static class OS @@ -13,6 +15,7 @@ public interface IBackend string FindGitExecutable(); string FindVSCode(); + string FindFleet(); void OpenTerminal(string workdir); void OpenInFileManager(string path, bool select); @@ -20,39 +23,36 @@ public interface IBackend void OpenWithDefaultEditor(string file); } - public static string GitInstallPath - { - get; - set; - } + public static string GitInstallPath { get; set; } - public static string VSCodeExecutableFile + 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 Platforms Platform => OperatingSystem.IsWindows() ? Platforms.Windows : OperatingSystem.IsMacOS() ? Platforms.MacOS : OperatingSystem.IsLinux() ? Platforms.Linux : Platforms.Unknown; + static OS() { - if (OperatingSystem.IsMacOS()) - { - _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 + _backend = Platform switch { - 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 @@ public static void OpenInVSCode(string repo) 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 14f04aecc6..ead733f1fe 100644 --- a/src/SourceGit/Native/Windows.cs +++ b/src/SourceGit/Native/Windows.cs @@ -103,34 +103,15 @@ public string FindGitExecutable() 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 toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe"); + if (File.Exists(toolPath)) return toolPath; + return string.Empty; + } + + public string FindFleet() + { + var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Fleet\\Fleet.exe"); + if (File.Exists(toolPath)) return toolPath; 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 0000000000..3ab51b6e70 --- /dev/null +++ b/src/SourceGit/Resources/ExternalToolIcons/fleet_icon.svg @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SourceGit/Resources/ExternalToolIcons/vscode_icon.svg b/src/SourceGit/Resources/ExternalToolIcons/vscode_icon.svg new file mode 100644 index 0000000000..8d9e0b08aa --- /dev/null +++ b/src/SourceGit/Resources/ExternalToolIcons/vscode_icon.svg @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/src/SourceGit/Resources/Icons.axaml b/src/SourceGit/Resources/Icons.axaml index 6b2c321741..20b605f26b 100644 --- a/src/SourceGit/Resources/Icons.axaml +++ b/src/SourceGit/Resources/Icons.axaml @@ -80,7 +80,6 @@ M520 168C291 168 95 311 16 512c79 201 275 344 504 344 229 0 425-143 504-344-79-201-275-344-504-344zm0 573c-126 0-229-103-229-229s103-229 229-229c126 0 229 103 229 229s-103 229-229 229zm0-367c-76 0-137 62-137 137s62 137 137 137S657 588 657 512s-62-137-137-137z M734 128c-33-19-74-8-93 25l-41 70c-28-6-58-9-90-9-294 0-445 298-445 298s82 149 231 236l-31 54c-19 33-8 74 25 93 33 19 74 8 93-25L759 222C778 189 767 147 734 128zM305 512c0-115 93-208 207-208 14 0 27 1 40 4l-37 64c-1 0-2 0-2 0-77 0-140 63-140 140 0 26 7 51 20 71l-37 64C324 611 305 564 305 512zM771 301 700 423c13 27 20 57 20 89 0 110-84 200-192 208l-51 89c12 1 24 2 36 2 292 0 446-298 446-298S895 388 771 301z M469 235V107h85v128h-85zm-162-94 85 85-60 60-85-85 60-60zm469 60-85 85-60-60 85-85 60 60zm-549 183A85 85 0 01302 341H722a85 85 0 0174 42l131 225A85 85 0 01939 652V832a85 85 0 01-85 85H171a85 85 0 01-85-85v-180a85 85 0 0112-43l131-225zM722 427H302l-100 171h255l10 29a59 59 0 002 5c2 4 5 9 9 14 8 9 18 17 34 17 16 0 26-7 34-17a72 72 0 0011-18l0-0 10-29h255l-100-171zM853 683H624a155 155 0 01-12 17C593 722 560 747 512 747c-48 0-81-25-99-47a155 155 0 01-12-17H171v149h683v-149z - M719 85 388 417l-209-165L87 299v427l92 47 210-164L720 939 939 850V171zM186 610V412l104 104zm526 55L514 512l198-153z M447 561a26 26 0 0126 26v171H421v-171a26 26 0 0126-26zm-98 65a26 26 0 0126 26v104H323v-104a26 26 0 0126-26zm0 0M561 268a32 32 0 0132 30v457h-65V299a32 32 0 0132-32zm0 0M675 384a26 26 0 0126 26v348H649v-350a26 26 0 0126-24zm0 0M801 223v579H223V223h579M805 171H219A49 49 0 00171 219v585A49 49 0 00219 853h585A49 49 0 00853 805V219A49 49 0 00805 171z M512 0C229.216 0 0 229.216 0 512c0 282.752 229.216 512 512 512s512-229.248 512-512c0-282.784-229.216-512-512-512z m0 957.92C266.112 957.92 66.08 757.888 66.08 512S266.112 66.08 512 66.08 957.92 266.112 957.92 512 757.888 957.92 512 957.92zM192 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM384 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM576 416h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM832 320h-64a32 32 0 0 0-32 32v128h-160a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h256a32 32 0 0 0 32-32v-192a32 32 0 0 0-32-32zM320 544v-32a32 32 0 0 0-32-32H192a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h96a32 32 0 0 0 32-32zM384 576h96a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32h-96a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32zM800 640H256a32 32 0 0 0-32 32v32a32 32 0 0 0 32 32h544a32 32 0 0 0 32-32v-32a32 32 0 0 0-32-32z M875 117H149C109 117 75 151 75 192v640c0 41 34 75 75 75h725c41 0 75-34 75-75V192c0-41-34-75-75-75zM139 832V192c0-6 4-11 11-11h331v661H149c-6 0-11-4-11-11zm747 0c0 6-4 11-11 11H544v-661H875c6 0 11 4 11 11v640z diff --git a/src/SourceGit/Resources/Locales.Designer.cs b/src/SourceGit/Resources/Locales.Designer.cs index ba49250436..eda36811a6 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 @@ public static string Text_Repository_Explore { } } + /// + /// 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. /// @@ -2985,6 +2993,15 @@ public static string Text_Repository_NewBranch { } } + /// + /// Looks up a localized string similar to Open in. + /// + public static string Text_Repository_OpenWith { + get { + return ResourceManager.GetString("Text.Repository.OpenWith", resourceCulture); + } + } + /// /// Looks up a localized string similar to Refresh. /// diff --git a/src/SourceGit/Resources/Locales.en.resx b/src/SourceGit/Resources/Locales.en.resx index 2f9e7bdd1e..884665b7ab 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 @@ -1302,6 +1305,9 @@ APPEARANCE + + Open in + Software Update diff --git a/src/SourceGit/Resources/Locales.resx b/src/SourceGit/Resources/Locales.resx index 8e06cd4d82..cb640c7288 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 @@ -1302,6 +1305,9 @@ Appearance + + Open in + Software Update diff --git a/src/SourceGit/SourceGit.csproj b/src/SourceGit/SourceGit.csproj index 0edbbb2fda..9dbaa5c540 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 ee684ee37e..76444e6e95 100644 --- a/src/SourceGit/ViewModels/Repository.cs +++ b/src/SourceGit/ViewModels/Repository.cs @@ -54,6 +54,12 @@ public bool IsVSCodeFound { 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 @@ public void OpenInVSCode() { 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 9759ba008e..5518279cf1 100644 --- a/src/SourceGit/Views/Repository.axaml +++ b/src/SourceGit/Views/Repository.axaml @@ -17,21 +17,34 @@ - - - - - - + + + + + diff --git a/src/SourceGit/Views/Repository.axaml.cs b/src/SourceGit/Views/Repository.axaml.cs index a5b33da758..ba0f271ae9 100644 --- a/src/SourceGit/Views/Repository.axaml.cs +++ b/src/SourceGit/Views/Repository.axaml.cs @@ -291,5 +291,14 @@ private async void OpenStatistics(object sender, RoutedEventArgs e) e.Handled = true; } } + + private void OpenInVSCode(object sender, RoutedEventArgs e) + { + (DataContext as ViewModels.Repository).OpenInVSCode(); + } + private void OpenInFleet(object sender, RoutedEventArgs e) + { + (DataContext as ViewModels.Repository).OpenInFleet(); + } } } \ No newline at end of file