|
1 | 1 | using System.Diagnostics; |
2 | 2 | using System.Runtime.Versioning; |
| 3 | +using StabilityMatrix.Core.Exceptions; |
3 | 4 | using StabilityMatrix.Core.Models; |
4 | 5 | using StabilityMatrix.Core.Models.FileInterfaces; |
5 | 6 | using StabilityMatrix.Core.Models.Packages; |
@@ -113,16 +114,38 @@ async Task CloneGitRepository( |
113 | 114 | // If pinning to a specific commit, we need a destination directory to continue |
114 | 115 | if (!string.IsNullOrWhiteSpace(version?.CommitSha)) |
115 | 116 | { |
116 | | - await RunGit(["fetch", "--depth", "1", "origin", version.CommitSha!], onProcessOutput, rootDir) |
117 | | - .ConfigureAwait(false); |
118 | | - await RunGit(["checkout", "--force", version.CommitSha!], onProcessOutput, rootDir) |
119 | | - .ConfigureAwait(false); |
120 | | - await RunGit( |
121 | | - ["submodule", "update", "--init", "--recursive", "--depth", "1"], |
122 | | - onProcessOutput, |
123 | | - rootDir |
124 | | - ) |
125 | | - .ConfigureAwait(false); |
| 117 | + try |
| 118 | + { |
| 119 | + await RunGit( |
| 120 | + ["fetch", "--depth", "1", "origin", version.CommitSha!], |
| 121 | + onProcessOutput, |
| 122 | + rootDir |
| 123 | + ) |
| 124 | + .ConfigureAwait(false); |
| 125 | + await RunGit(["checkout", "--force", version.CommitSha!], onProcessOutput, rootDir) |
| 126 | + .ConfigureAwait(false); |
| 127 | + await RunGit( |
| 128 | + ["submodule", "update", "--init", "--recursive", "--depth", "1"], |
| 129 | + onProcessOutput, |
| 130 | + rootDir |
| 131 | + ) |
| 132 | + .ConfigureAwait(false); |
| 133 | + } |
| 134 | + catch (ProcessException ex) |
| 135 | + { |
| 136 | + if (ex.Message.Contains("Git exited with code 128")) |
| 137 | + { |
| 138 | + onProcessOutput?.Invoke( |
| 139 | + ProcessOutput.FromStdErrLine( |
| 140 | + $"Unable to check out commit {version.CommitSha} - continuing with latest commit from {version.Branch}\n\n{ex.ProcessResult?.StandardError}\n" |
| 141 | + ) |
| 142 | + ); |
| 143 | + } |
| 144 | + else |
| 145 | + { |
| 146 | + throw; |
| 147 | + } |
| 148 | + } |
126 | 149 | } |
127 | 150 | } |
128 | 151 |
|
|
0 commit comments