Skip to content

Commit bfbc9a2

Browse files
committed
Feature: Enhanced Git Support (SSH Agent & Status Center) (#17692)
- Implemented SSH key authentication by integrating with the system OpenSSH Agent, resolving compatibility issues with LibGit2Sharp 0.31.0 and enabling support for passphrase-protected keys. - Integrated Git Push, Fetch, and Pull operations with the Status Center to provide real-time progress feedback (items processed, transfer bytes). - Fixed the issue where the Git Status Bar (commits ahead/behind) would not refresh automatically after remote operations. - Refactored FetchOrigin and PullOriginAsync to use async/await and perform operations on background threads, preventing UI freezes. - Removed the obsolete GitPassphraseDialog and custom SSH credential handling logic in favor of the native agent. - Added GitFetch and GitPull to FileOperationType and updated Resources.resw with localized strings for these operations. Closes #17692
1 parent 2e7b3dd commit bfbc9a2

File tree

6 files changed

+508
-70
lines changed

6 files changed

+508
-70
lines changed

Directory.Packages.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
<PackageVersion Include="CommunityToolkit.WinUI.Triggers" Version="8.2.251219" />
2222
<PackageVersion Include="DiscUtils.Udf" Version="0.16.13" />
2323
<PackageVersion Include="FluentFTP" Version="53.0.2" />
24-
<!-- Note, 0.31 causes issues with repos cloned via ssh -->
25-
<PackageVersion Include="LibGit2Sharp" Version="0.30.0" />
24+
<PackageVersion Include="LibGit2Sharp" Version="0.31.0" />
2625
<PackageVersion Include="MessageFormat" Version="7.1.3" />
2726
<PackageVersion Include="Microsoft.Data.Sqlite.Core" Version="9.0.9" />
2827
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />

src/Files.App/Actions/Git/GitFetchAction.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ public GitFetchAction()
2424
_context.PropertyChanged += Context_PropertyChanged;
2525
}
2626

27-
public Task ExecuteAsync(object? parameter = null)
27+
public async Task ExecuteAsync(object? parameter = null)
2828
{
29-
GitHelpers.FetchOrigin(_context.ShellPage!.InstanceViewModel.GitRepositoryPath);
30-
31-
return Task.CompletedTask;
29+
await GitHelpers.FetchOrigin(_context.ShellPage!.InstanceViewModel.GitRepositoryPath);
3230
}
3331

3432
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)

src/Files.App/Data/Enums/FileOperationType.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,20 @@ public enum FileOperationType : byte
7272
/// A font has been installed
7373
/// </summary>
7474
InstallFont = 13,
75+
76+
/// <summary>
77+
/// A git repo has been pushed
78+
/// </summary>
79+
GitPush = 14,
80+
81+
/// <summary>
82+
/// A git repo has been fetched
83+
/// </summary>
84+
GitFetch = 15,
85+
86+
/// <summary>
87+
/// A git repo has been pulled
88+
/// </summary>
89+
GitPull = 16,
7590
}
7691
}

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3738,6 +3738,102 @@
37383738
<value>Failed to empty Recycle Bin</value>
37393739
<comment>Shown in a StatusCenter card.</comment>
37403740
</data>
3741+
<data name="StatusCenter_GitPushCanceled_Header" xml:space="preserve">
3742+
<value>Canceled pushing to "{0}"</value>
3743+
<comment>Shown in a StatusCenter card.</comment>
3744+
</data>
3745+
<data name="StatusCenter_GitPushCanceled_SubHeader" xml:space="preserve">
3746+
<value>Canceled pushing branch "{0}" to "{1}"</value>
3747+
<comment>Shown in a StatusCenter card.</comment>
3748+
</data>
3749+
<data name="StatusCenter_GitPushComplete_Header" xml:space="preserve">
3750+
<value>Pushed to "{0}"</value>
3751+
<comment>Shown in a StatusCenter card.</comment>
3752+
</data>
3753+
<data name="StatusCenter_GitPushComplete_SubHeader" xml:space="preserve">
3754+
<value>Pushed branch "{0}" to "{1}"</value>
3755+
<comment>Shown in a StatusCenter card.</comment>
3756+
</data>
3757+
<data name="StatusCenter_GitPushFailed_Header" xml:space="preserve">
3758+
<value>Error pushing to "{0}"</value>
3759+
<comment>Shown in a StatusCenter card.</comment>
3760+
</data>
3761+
<data name="StatusCenter_GitPushFailed_SubHeader" xml:space="preserve">
3762+
<value>Failed to push branch "{0}" to "{1}"</value>
3763+
<comment>Shown in a StatusCenter card.</comment>
3764+
</data>
3765+
<data name="StatusCenter_GitPushInProgress_Header" xml:space="preserve">
3766+
<value>Pushing to "{0}"</value>
3767+
<comment>Shown in a StatusCenter card.</comment>
3768+
</data>
3769+
<data name="StatusCenter_GitPushInProgress_SubHeader" xml:space="preserve">
3770+
<value>Pushing branch "{0}" to "{1}"</value>
3771+
<comment>Shown in a StatusCenter card.</comment>
3772+
</data>
3773+
<data name="StatusCenter_GitFetchCanceled_Header" xml:space="preserve">
3774+
<value>Canceled fetching from "{0}"</value>
3775+
<comment>Shown in a StatusCenter card.</comment>
3776+
</data>
3777+
<data name="StatusCenter_GitFetchCanceled_SubHeader" xml:space="preserve">
3778+
<value>Canceled fetching from "{0}"</value>
3779+
<comment>Shown in a StatusCenter card.</comment>
3780+
</data>
3781+
<data name="StatusCenter_GitFetchComplete_Header" xml:space="preserve">
3782+
<value>Fetched from "{0}"</value>
3783+
<comment>Shown in a StatusCenter card.</comment>
3784+
</data>
3785+
<data name="StatusCenter_GitFetchComplete_SubHeader" xml:space="preserve">
3786+
<value>Fetched from "{0}"</value>
3787+
<comment>Shown in a StatusCenter card.</comment>
3788+
</data>
3789+
<data name="StatusCenter_GitFetchFailed_Header" xml:space="preserve">
3790+
<value>Error fetching from "{0}"</value>
3791+
<comment>Shown in a StatusCenter card.</comment>
3792+
</data>
3793+
<data name="StatusCenter_GitFetchFailed_SubHeader" xml:space="preserve">
3794+
<value>Failed to fetch from "{0}"</value>
3795+
<comment>Shown in a StatusCenter card.</comment>
3796+
</data>
3797+
<data name="StatusCenter_GitFetchInProgress_Header" xml:space="preserve">
3798+
<value>Fetching from "{0}"</value>
3799+
<comment>Shown in a StatusCenter card.</comment>
3800+
</data>
3801+
<data name="StatusCenter_GitFetchInProgress_SubHeader" xml:space="preserve">
3802+
<value>Fetching from "{0}"</value>
3803+
<comment>Shown in a StatusCenter card.</comment>
3804+
</data>
3805+
<data name="StatusCenter_GitPullCanceled_Header" xml:space="preserve">
3806+
<value>Canceled pulling from "{0}"</value>
3807+
<comment>Shown in a StatusCenter card.</comment>
3808+
</data>
3809+
<data name="StatusCenter_GitPullCanceled_SubHeader" xml:space="preserve">
3810+
<value>Canceled pulling branch "{0}" from "{1}"</value>
3811+
<comment>Shown in a StatusCenter card.</comment>
3812+
</data>
3813+
<data name="StatusCenter_GitPullComplete_Header" xml:space="preserve">
3814+
<value>Pulled from "{0}"</value>
3815+
<comment>Shown in a StatusCenter card.</comment>
3816+
</data>
3817+
<data name="StatusCenter_GitPullComplete_SubHeader" xml:space="preserve">
3818+
<value>Pulled branch "{0}" from "{1}"</value>
3819+
<comment>Shown in a StatusCenter card.</comment>
3820+
</data>
3821+
<data name="StatusCenter_GitPullFailed_Header" xml:space="preserve">
3822+
<value>Error pulling from "{0}"</value>
3823+
<comment>Shown in a StatusCenter card.</comment>
3824+
</data>
3825+
<data name="StatusCenter_GitPullFailed_SubHeader" xml:space="preserve">
3826+
<value>Failed to pull branch "{0}" from "{1}"</value>
3827+
<comment>Shown in a StatusCenter card.</comment>
3828+
</data>
3829+
<data name="StatusCenter_GitPullInProgress_Header" xml:space="preserve">
3830+
<value>Pulling from "{0}"</value>
3831+
<comment>Shown in a StatusCenter card.</comment>
3832+
</data>
3833+
<data name="StatusCenter_GitPullInProgress_SubHeader" xml:space="preserve">
3834+
<value>Pulling branch "{0}" from "{1}"</value>
3835+
<comment>Shown in a StatusCenter card.</comment>
3836+
</data>
37413837
<data name="StatusCenter_Prepare_Header" xml:space="preserve">
37423838
<value>Preparing the operation...</value>
37433839
<comment>Shown in a StatusCenter card.</comment>

0 commit comments

Comments
 (0)