This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-17
lines changed
src/GitHub.Exports/Services Expand file tree Collapse file tree 1 file changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -85,30 +85,31 @@ public UriString GetRemoteUri(IRepository repo, string remote = "origin")
8585 public Task < string > GetLatestPushedSha ( string path )
8686 {
8787 Guard . ArgumentNotNull ( path , nameof ( path ) ) ;
88- using ( var repo = GetRepository ( path ) )
89- {
90- if ( repo == null )
91- return null ;
9288
93- if ( repo . Head . IsTracking && repo . Head . Tip . Sha == repo . Head . TrackedBranch . Tip . Sha )
94- {
95- return Task . FromResult ( repo . Head . Tip . Sha ) ;
96- }
97-
98- return Task . Factory . StartNew ( ( ) =>
89+ return Task . Factory . StartNew ( ( ) =>
90+ {
91+ using ( var repo = GetRepository ( path ) )
9992 {
100- var remoteHeads = repo . Refs . Where ( r => r . IsRemoteTrackingBranch ) . ToList ( ) ;
101-
102- foreach ( var c in repo . Commits )
93+ if ( repo != null )
10394 {
104- if ( repo . Refs . ReachableFrom ( remoteHeads , new [ ] { c } ) . Any ( ) )
95+ if ( repo . Head . IsTracking && repo . Head . Tip . Sha == repo . Head . TrackedBranch . Tip . Sha )
96+ {
97+ return repo . Head . Tip . Sha ;
98+ }
99+
100+ var remoteHeads = repo . Refs . Where ( r => r . IsRemoteTrackingBranch ) . ToList ( ) ;
101+ foreach ( var c in repo . Commits )
105102 {
106- return c . Sha ;
103+ if ( repo . Refs . ReachableFrom ( remoteHeads , new [ ] { c } ) . Any ( ) )
104+ {
105+ return c . Sha ;
106+ }
107107 }
108108 }
109+
109110 return null ;
110- } ) ;
111- }
111+ }
112+ } ) ;
112113 }
113114 }
114115}
You can’t perform that action at this time.
0 commit comments