Skip to content

Commit 6f670b1

Browse files
committed
feature: support open -a SourceGit <path> on macOS (#2553)
Signed-off-by: leo <longshuang@msn.cn>
1 parent ba56baf commit 6f670b1

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎build/resources/app/App.plist‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@
2020
<string>APPL</string>
2121
<key>CFBundleShortVersionString</key>
2222
<string>SOURCE_GIT_VERSION</string>
23+
<key>CFBundleDocumentTypes</key>
24+
<array>
25+
<dict>
26+
<key>CFBundleTypeName</key>
27+
<string>Supported Folder</string>
28+
<key>CFBundleTypeRole</key>
29+
<string>Viewer</string>
30+
<key>LSHandlerRank</key>
31+
<string>Alternate</string>
32+
<key>LSItemContentTypes</key>
33+
<array>
34+
<string>public.folder</string>
35+
</array>
36+
</dict>
37+
</array>
2338
<key>NSHighResolutionCapable</key>
2439
<true/>
2540
</dict>

‎src/App.axaml.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Avalonia.Markup.Xaml;
1212
using Avalonia.Media;
1313
using Avalonia.Media.Fonts;
14+
using Avalonia.Platform;
1415
using Avalonia.Styling;
1516
using Avalonia.Threading;
1617

@@ -475,6 +476,15 @@ private void TryLaunchAsNormal(IClassicDesktopStyleApplicationLifetime desktop)
475476
Native.OS.SetupExternalTools();
476477
Models.AvatarManager.Instance.Start();
477478

479+
if (this.TryGetFeature<IActivatableLifetime>() is { } activatable)
480+
{
481+
activatable.Activated += (_, e) =>
482+
{
483+
if (e is FileActivatedEventArgs { Files: { Count: > 0 } } fileArgs)
484+
_launcher?.TryOpenRepositoryFromPath(fileArgs.Files[0].Path.LocalPath);
485+
};
486+
}
487+
478488
string startupRepo = null;
479489
if (desktop.Args is { Length: 1 })
480490
{

0 commit comments

Comments
 (0)