22using KGySoft . CoreLibraries ;
33using Microsoft . Extensions . Caching . Memory ;
44using NLog ;
5+ using StabilityMatrix . Core . Exceptions ;
56using StabilityMatrix . Core . Extensions ;
67using StabilityMatrix . Core . Helper ;
78using StabilityMatrix . Core . Models . FileInterfaces ;
@@ -80,9 +81,10 @@ public virtual async Task<IEnumerable<InstalledPackageExtension>> GetInstalledEx
8081
8182 // Search for installed extensions in the package's index directories.
8283 foreach (
83- var indexDirectory in IndexRelativeDirectories . Select (
84- path => new DirectoryPath ( packagePath , path )
85- )
84+ var indexDirectory in IndexRelativeDirectories . Select ( path => new DirectoryPath (
85+ packagePath ,
86+ path
87+ ) )
8688 )
8789 {
8890 cancellationToken . ThrowIfCancellationRequested ( ) ;
@@ -120,11 +122,11 @@ var indexDirectory in IndexRelativeDirectories.Select(
120122 {
121123 Tag = version . Tag ,
122124 Branch = version . Branch ,
123- CommitSha = version . CommitSha
125+ CommitSha = version . CommitSha ,
124126 } ,
125127 GitRepositoryUrl = remoteUrlResult . IsSuccessExitCode
126128 ? remoteUrlResult . StandardOutput ? . Trim ( )
127- : null
129+ : null ,
128130 }
129131 ) ;
130132 }
@@ -150,9 +152,10 @@ public virtual async Task<IEnumerable<InstalledPackageExtension>> GetInstalledEx
150152
151153 // Search for installed extensions in the package's index directories.
152154 foreach (
153- var indexDirectory in IndexRelativeDirectories . Select (
154- path => new DirectoryPath ( packagePath , path )
155- )
155+ var indexDirectory in IndexRelativeDirectories . Select ( path => new DirectoryPath (
156+ packagePath ,
157+ path
158+ ) )
156159 )
157160 {
158161 cancellationToken . ThrowIfCancellationRequested ( ) ;
@@ -221,8 +224,8 @@ InstalledPackageExtension installedExtension
221224 {
222225 Tag = version . Tag ,
223226 Branch = version . Branch ,
224- CommitSha = version . CommitSha
225- }
227+ CommitSha = version . CommitSha ,
228+ } ,
226229 } ;
227230 }
228231
@@ -257,14 +260,34 @@ public virtual async Task InstallExtensionAsync(
257260 new ProgressReport ( 0f , message : $ "Cloning { repositoryUri } ", isIndeterminate : true )
258261 ) ;
259262
260- await prerequisiteHelper
261- . CloneGitRepository (
262- cloneRoot ,
263- repositoryUri . ToString ( ) ,
264- version ,
265- progress . AsProcessOutputHandler ( )
266- )
267- . ConfigureAwait ( false ) ;
263+ try
264+ {
265+ await prerequisiteHelper
266+ . CloneGitRepository (
267+ cloneRoot ,
268+ repositoryUri . ToString ( ) ,
269+ version ,
270+ progress . AsProcessOutputHandler ( )
271+ )
272+ . ConfigureAwait ( false ) ;
273+ }
274+ catch ( ProcessException ex )
275+ {
276+ if ( ex . Message . Contains ( "Git exited with code 128" ) )
277+ {
278+ progress ? . Report (
279+ new ProgressReport (
280+ - 1f ,
281+ $ "Unable to check out commit { version ? . CommitSha } - continuing with latest commit from { version ? . Branch } \n \n { ex . ProcessResult ? . StandardError } \n ",
282+ isIndeterminate : true
283+ )
284+ ) ;
285+ }
286+ else
287+ {
288+ throw ;
289+ }
290+ }
268291
269292 progress ? . Report ( new ProgressReport ( 1f , message : $ "Cloned { repositoryUri } ") ) ;
270293 }
0 commit comments