Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit f894e2a

Browse files
committed
Convert to use IProgress<string> rather than Delegate<string>
1 parent 40b81dc commit f894e2a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ public async Task SyncSubmodules(ILocalRepositoryModel repository)
196196
}
197197

198198
var output = new StringWriter(CultureInfo.InvariantCulture);
199-
exitCode = await SyncSubmodules(repository.LocalPath, line => output.WriteLine(line));
199+
var progress = new Progress<string>(line => output.WriteLine(line));
200+
exitCode = await SyncSubmodules(repository.LocalPath, progress);
200201
if (exitCode != 0)
201202
{
202203
var message = output.ToString();
@@ -205,7 +206,7 @@ public async Task SyncSubmodules(ILocalRepositoryModel repository)
205206
}
206207

207208
// LibGit2Sharp has limited submodule support so shelling out Git.exe for submodule commands.
208-
async Task<int> SyncSubmodules(string workingDir, Action<string> progress = null)
209+
async Task<int> SyncSubmodules(string workingDir, IProgress<string> progress)
209210
{
210211
var cmdArguments = "/C git submodule init & git submodule sync --recursive & git submodule update --recursive";
211212
var startInfo = new ProcessStartInfo("cmd", cmdArguments)
@@ -243,12 +244,12 @@ static int Where(string fileName)
243244
}
244245
}
245246

246-
static async Task ReadLinesAsync(TextReader reader, Action<string> progress)
247+
static async Task ReadLinesAsync(TextReader reader, IProgress<string> progress)
247248
{
248249
string line;
249250
while ((line = await reader.ReadLineAsync()) != null)
250251
{
251-
progress?.Invoke(line);
252+
progress.Report(line);
252253
}
253254
}
254255

0 commit comments

Comments
 (0)