@@ -25,6 +25,9 @@ internal static partial class GitHelpers
2525 /// <inheritdoc cref="IVersionControl.GetBranchNames(string?)"/>
2626 public static Task < BranchItem [ ] > GetBranchNames ( string ? path ) => _implementation . GetBranchNames ( path ) ;
2727
28+ /// <inheritdoc cref="IVersionControl.GetRepositoryHead(string?)"/>
29+ public static Task < BranchItem ? > GetRepositoryHead ( string ? path ) => _implementation . GetRepositoryHead ( path ) ;
30+
2831 #region Legacy implementation
2932
3033 // Property already moved into abstraction
@@ -91,38 +94,6 @@ private set
9194 // Event handler already moved into abstraction
9295 public static event EventHandler ? GitFetchCompleted ;
9396
94- public static async Task < BranchItem ? > GetRepositoryHead ( string ? path )
95- {
96- if ( string . IsNullOrWhiteSpace ( path ) || ! IsRepoValid ( path ) )
97- return null ;
98-
99- var ( _, returnValue ) = await DoGitOperationAsync < ( GitOperationResult , BranchItem ? ) > ( ( ) =>
100- {
101- BranchItem ? head = null ;
102- try
103- {
104- using var repository = new Repository ( path ) ;
105- var branch = GetValidBranches ( repository . Branches ) . FirstOrDefault ( b => b . IsCurrentRepositoryHead ) ;
106- if ( branch is not null )
107- head = new BranchItem (
108- branch . FriendlyName ,
109- branch . IsCurrentRepositoryHead ,
110- branch . IsRemote ,
111- TryGetTrackingDetails ( branch ) ? . AheadBy ?? 0 ,
112- TryGetTrackingDetails ( branch ) ? . BehindBy ?? 0
113- ) ;
114- }
115- catch
116- {
117- return ( GitOperationResult . GenericError , head ) ;
118- }
119-
120- return ( GitOperationResult . Success , head ) ;
121- } , true ) ;
122-
123- return returnValue ;
124- }
125-
12697 public static async Task < bool > Checkout ( string ? repositoryPath , string ? branch )
12798 {
12899 // Re-enable when Metris feature is available again
0 commit comments