Skip to content

Commit 7866a11

Browse files
committed
Merge branch 'feature/open_with' from PR #33
2 parents 760d64c + 4659fbd commit 7866a11

File tree

13 files changed

+142
-82
lines changed

13 files changed

+142
-82
lines changed

src/SourceGit/Native/Linux.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Diagnostics;
1+
using System;
2+
using System.Diagnostics;
23
using System.IO;
34
using System.Runtime.Versioning;
45

@@ -30,7 +31,15 @@ public string FindGitExecutable()
3031

3132
public string FindVSCode()
3233
{
33-
if (File.Exists("/usr/share/code/code")) return "/usr/share/code/code";
34+
var toolPath = "/usr/share/code/code";
35+
if (File.Exists(toolPath)) return toolPath;
36+
return string.Empty;
37+
}
38+
39+
public string FindFleet()
40+
{
41+
var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/.local/share/JetBrains/Toolbox/apps/fleet/bin/Fleet";
42+
if (File.Exists(toolPath)) return toolPath;
3443
return string.Empty;
3544
}
3645

src/SourceGit/Native/MacOS.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Diagnostics;
1+
using System;
2+
using System.Diagnostics;
23
using System.IO;
34
using System.Runtime.Versioning;
45
using System.Text;
@@ -27,11 +28,17 @@ public string FindGitExecutable()
2728

2829
public string FindVSCode()
2930
{
30-
if (File.Exists("/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"))
31-
{
32-
return "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
33-
}
34-
31+
var toolPath = "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code";
32+
if (File.Exists(toolPath))
33+
return toolPath;
34+
return string.Empty;
35+
}
36+
37+
public string FindFleet()
38+
{
39+
var toolPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Applications/Fleet.app/Contents/MacOS/Fleet";
40+
if (File.Exists(toolPath))
41+
return toolPath;
3542
return string.Empty;
3643
}
3744

src/SourceGit/Native/OS.cs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,41 @@ public interface IBackend
1313

1414
string FindGitExecutable();
1515
string FindVSCode();
16+
string FindFleet();
1617

1718
void OpenTerminal(string workdir);
1819
void OpenInFileManager(string path, bool select);
1920
void OpenBrowser(string url);
2021
void OpenWithDefaultEditor(string file);
2122
}
2223

23-
public static string GitInstallPath
24-
{
25-
get;
26-
set;
27-
}
24+
public static string GitInstallPath { get; set; }
2825

29-
public static string VSCodeExecutableFile
30-
{
31-
get;
32-
set;
33-
}
26+
public static string VSCodeExecutableFile { get; set; }
27+
28+
public static string FleetExecutableFile { get; set; }
3429

3530
static OS()
3631
{
37-
if (OperatingSystem.IsMacOS())
32+
if (OperatingSystem.IsWindows())
3833
{
39-
_backend = new MacOS();
40-
VSCodeExecutableFile = _backend.FindVSCode();
34+
_backend = new Windows();
4135
}
42-
else if (OperatingSystem.IsWindows())
36+
else if (OperatingSystem.IsMacOS())
4337
{
44-
_backend = new Windows();
45-
VSCodeExecutableFile = _backend.FindVSCode();
38+
_backend = new MacOS();
4639
}
4740
else if (OperatingSystem.IsLinux())
4841
{
4942
_backend = new Linux();
50-
VSCodeExecutableFile = _backend.FindVSCode();
5143
}
5244
else
5345
{
5446
throw new Exception("Platform unsupported!!!");
5547
}
48+
49+
VSCodeExecutableFile = _backend.FindVSCode();
50+
FleetExecutableFile = _backend.FindFleet();
5651
}
5752

5853
public static void SetupApp(AppBuilder builder)
@@ -103,5 +98,22 @@ public static void OpenInVSCode(string repo)
10398
}
10499

105100
private static readonly IBackend _backend = null;
101+
102+
public static void OpenInFleet(string repo)
103+
{
104+
if (string.IsNullOrEmpty(FleetExecutableFile))
105+
{
106+
App.RaiseException(repo, "Fleet can NOT be found in your system!!!");
107+
return;
108+
}
109+
110+
Process.Start(new ProcessStartInfo()
111+
{
112+
WorkingDirectory = repo,
113+
FileName = FleetExecutableFile,
114+
Arguments = $"\"{repo}\"",
115+
UseShellExecute = false,
116+
});
117+
}
106118
}
107119
}

src/SourceGit/Native/Windows.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,30 +116,21 @@ public string FindVSCode()
116116
Microsoft.Win32.RegistryHive.LocalMachine,
117117
Environment.Is64BitOperatingSystem ? Microsoft.Win32.RegistryView.Registry64 : Microsoft.Win32.RegistryView.Registry32);
118118

119-
var vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{C26E74D1-022E-4238-8B9D-1E7564A36CC9}_is1");
119+
var vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1");
120120
if (vscode != null)
121121
{
122122
return vscode.GetValue("DisplayIcon") as string;
123123
}
124124

125-
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{1287CAD5-7C8D-410D-88B9-0D1EE4A83FF2}_is1");
126-
if (vscode != null)
127-
{
128-
return vscode.GetValue("DisplayIcon") as string;
129-
}
130-
131-
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F8A2A208-72B3-4D61-95FC-8A65D340689B}_is1");
132-
if (vscode != null)
133-
{
134-
return vscode.GetValue("DisplayIcon") as string;
135-
}
136-
137-
vscode = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EA457B21-F73E-494C-ACAB-524FDE069978}_is1");
138-
if (vscode != null)
139-
{
140-
return vscode.GetValue("DisplayIcon") as string;
141-
}
125+
var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe");
126+
if (File.Exists(toolPath)) return toolPath;
127+
return string.Empty;
128+
}
142129

130+
public string FindFleet()
131+
{
132+
var toolPath = Environment.ExpandEnvironmentVariables($"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\AppData\\Local\\Programs\\Fleet\\Fleet.exe");
133+
if (File.Exists(toolPath)) return toolPath;
143134
return string.Empty;
144135
}
145136

5.1 KB
Loading
2.5 KB
Loading

src/SourceGit/Resources/Icons.axaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
<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>
8181
<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>
8282
<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>
83-
<StreamGeometry x:Key="Icons.VSCode">M719 85 388 417l-209-165L87 299v427l92 47 210-164L720 939 939 850V171zM186 610V412l104 104zm526 55L514 512l198-153z</StreamGeometry>
8483
<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>
8584
<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>
8685
<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>

src/SourceGit/Resources/Locales.Designer.cs

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SourceGit/Resources/Locales.en.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@
342342
<data xml:space="preserve" name="Text.Repository.VSCode">
343343
<value>Open In Visual Studio Code</value>
344344
</data>
345+
<data xml:space="preserve" name="Text.Repository.Fleet">
346+
<value>Open In Fleet</value>
347+
</data>
345348
<data xml:space="preserve" name="Text.Repository.Terminal">
346349
<value>Open In Git Bash</value>
347350
</data>
@@ -1302,6 +1305,9 @@
13021305
<data name="Text.Preference.Appearance" xml:space="preserve">
13031306
<value>APPEARANCE</value>
13041307
</data>
1308+
<data name="Text.Repository.OpenWith" xml:space="preserve">
1309+
<value>Open in</value>
1310+
</data>
13051311
<data name="Text.SelfUpdate.Title" xml:space="preserve">
13061312
<value>Software Update</value>
13071313
</data>

src/SourceGit/Resources/Locales.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@
342342
<data xml:space="preserve" name="Text.Repository.VSCode">
343343
<value>Open In Visual Studio Code</value>
344344
</data>
345+
<data xml:space="preserve" name="Text.Repository.Fleet">
346+
<value>Open In Fleet</value>
347+
</data>
345348
<data xml:space="preserve" name="Text.Repository.Terminal">
346349
<value>Open In Git Bash</value>
347350
</data>
@@ -1302,6 +1305,9 @@
13021305
<data name="Text.Preference.Appearance" xml:space="preserve">
13031306
<value>Appearance</value>
13041307
</data>
1308+
<data name="Text.Repository.OpenWith" xml:space="preserve">
1309+
<value>Open in</value>
1310+
</data>
13051311
<data name="Text.SelfUpdate.Title" xml:space="preserve">
13061312
<value>Software Update</value>
13071313
</data>

0 commit comments

Comments
 (0)