Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/SourceGit/Native/Linux.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Versioning;

Expand Down Expand Up @@ -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;
}

Expand Down
19 changes: 13 additions & 6 deletions src/SourceGit/Native/MacOS.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Versioning;
using System.Text;
Expand Down Expand Up @@ -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;
}

Expand Down
71 changes: 41 additions & 30 deletions src/SourceGit/Native/OS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using Avalonia;

// ReSharper disable InconsistentNaming

namespace SourceGit.Native
{
public static class OS
Expand All @@ -13,46 +15,44 @@ public interface IBackend

string FindGitExecutable();
string FindVSCode();
string FindFleet();

void OpenTerminal(string workdir);
void OpenInFileManager(string path, bool select);
void OpenBrowser(string url);
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)
Expand Down Expand Up @@ -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,
});
}
}
}
37 changes: 9 additions & 28 deletions src/SourceGit/Native/Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
50 changes: 50 additions & 0 deletions src/SourceGit/Resources/ExternalToolIcons/fleet_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/SourceGit/Resources/ExternalToolIcons/vscode_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/SourceGit/Resources/Icons.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<StreamGeometry x:Key="Icons.Eye">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</StreamGeometry>
<StreamGeometry x:Key="Icons.EyeClose">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</StreamGeometry>
<StreamGeometry x:Key="Icons.Empty">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</StreamGeometry>
<StreamGeometry x:Key="Icons.VSCode">M719 85 388 417l-209-165L87 299v427l92 47 210-164L720 939 939 850V171zM186 610V412l104 104zm526 55L514 512l198-153z</StreamGeometry>
<StreamGeometry x:Key="Icons.Statistics">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</StreamGeometry>
<StreamGeometry x:Key="Icons.Hotkeys">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</StreamGeometry>
<StreamGeometry x:Key="Icons.LayoutHorizontal">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</StreamGeometry>
Expand Down
19 changes: 18 additions & 1 deletion src/SourceGit/Resources/Locales.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/SourceGit/Resources/Locales.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@
<data xml:space="preserve" name="Text.Repository.VSCode">
<value>Open In Visual Studio Code</value>
</data>
<data xml:space="preserve" name="Text.Repository.Fleet">
<value>Open In Fleet</value>
</data>
<data xml:space="preserve" name="Text.Repository.Terminal">
<value>Open In Git Bash</value>
</data>
Expand Down Expand Up @@ -1302,6 +1305,9 @@
<data name="Text.Preference.Appearance" xml:space="preserve">
<value>APPEARANCE</value>
</data>
<data name="Text.Repository.OpenWith" xml:space="preserve">
<value>Open in</value>
</data>
<data name="Text.SelfUpdate.Title" xml:space="preserve">
<value>Software Update</value>
</data>
Expand Down
6 changes: 6 additions & 0 deletions src/SourceGit/Resources/Locales.resx
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@
<data xml:space="preserve" name="Text.Repository.VSCode">
<value>Open In Visual Studio Code</value>
</data>
<data xml:space="preserve" name="Text.Repository.Fleet">
<value>Open In Fleet</value>
</data>
<data xml:space="preserve" name="Text.Repository.Terminal">
<value>Open In Git Bash</value>
</data>
Expand Down Expand Up @@ -1302,6 +1305,9 @@
<data name="Text.Preference.Appearance" xml:space="preserve">
<value>Appearance</value>
</data>
<data name="Text.Repository.OpenWith" xml:space="preserve">
<value>Open in</value>
</data>
<data name="Text.SelfUpdate.Title" xml:space="preserve">
<value>Software Update</value>
</data>
Expand Down
5 changes: 5 additions & 0 deletions src/SourceGit/SourceGit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.10" />
<PackageReference Include="Avalonia.Svg" Version="11.0.0.16" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.10" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.10" />
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.0.6" />
Expand All @@ -57,4 +58,8 @@
<TrimmerRootAssembly Include="SourceGit" />
<TrimmerRootAssembly Include="Avalonia.Themes.Fluent" />
</ItemGroup>

<ItemGroup>
<AvaloniaResource Include="Resources\ExternalToolIcons\*" />
</ItemGroup>
</Project>
Loading