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

Commit 2820be9

Browse files
committed
Revert to using Action<string> instead of IProgress
1 parent fe20f56 commit 2820be9

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

src/GitHub.App/Services/PullRequestService.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,20 +186,20 @@ public IObservable<Unit> Push(ILocalRepositoryModel repository)
186186
});
187187
}
188188

189-
public async Task<bool> SyncSubmodules(ILocalRepositoryModel repository, IProgress<string> progress)
189+
public async Task<bool> SyncSubmodules(ILocalRepositoryModel repository, Action<string> progress)
190190
{
191191
var exitCode = await Where("git");
192192
if (exitCode != 0)
193193
{
194-
progress.Report(App.Resources.CouldntFindGitOnPath);
194+
progress(App.Resources.CouldntFindGitOnPath);
195195
return false;
196196
}
197197

198198
return await SyncSubmodules(repository.LocalPath, progress) == 0;
199199
}
200200

201201
// LibGit2Sharp has limited submodule support so shelling out Git.exe for submodule commands.
202-
async Task<int> SyncSubmodules(string workingDir, IProgress<string> progress)
202+
async Task<int> SyncSubmodules(string workingDir, Action<string> progress)
203203
{
204204
var cmdArguments = "/C git submodule init & git submodule sync --recursive & git submodule update --recursive";
205205
var startInfo = new ProcessStartInfo("cmd", cmdArguments)
@@ -240,12 +240,12 @@ static Task<int> Where(string fileName)
240240
});
241241
}
242242

243-
static async Task ReadLinesAsync(TextReader reader, IProgress<string> progress)
243+
static async Task ReadLinesAsync(TextReader reader, Action<string> progress)
244244
{
245245
string line;
246246
while ((line = await reader.ReadLineAsync()) != null)
247247
{
248-
progress.Report(line);
248+
progress(line);
249249
}
250250
}
251251

src/GitHub.App/ViewModels/GitHubPane/PullRequestDetailViewModel.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -683,11 +683,11 @@ async Task DoSyncSubmodules(object unused)
683683
IsBusy = true;
684684
usageTracker.IncrementCounter(x => x.NumberOfSyncSubmodules).Forget();
685685

686-
var progress = new CaptureProgress();
687-
var complete = await pullRequestsService.SyncSubmodules(LocalRepository, progress);
686+
var writer = new StringWriter(CultureInfo.CurrentCulture);
687+
var complete = await pullRequestsService.SyncSubmodules(LocalRepository, writer.WriteLine);
688688
if (!complete)
689689
{
690-
throw new ApplicationException(progress.ToString());
690+
throw new ApplicationException(writer.ToString());
691691
}
692692
}
693693
finally
@@ -696,18 +696,6 @@ async Task DoSyncSubmodules(object unused)
696696
}
697697
}
698698

699-
sealed class CaptureProgress : IProgress<string>, IDisposable
700-
{
701-
StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);
702-
public void Report(string value)
703-
{
704-
VisualStudio.Services.Dte.StatusBar.Text = value;
705-
writer.WriteLine(value);
706-
}
707-
public override string ToString() => writer.ToString();
708-
public void Dispose() => writer.Dispose();
709-
}
710-
711699
class CheckoutCommandState : IPullRequestCheckoutState
712700
{
713701
public CheckoutCommandState(string caption, string disabledMessage)

src/GitHub.Exports.Reactive/Services/IPullRequestService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ IObservable<IPullRequestModel> CreatePullRequest(IModelService modelService,
5656
/// Sync submodules on the current branch.
5757
/// </summary>
5858
/// <param name="repository">The repository.</param>
59-
Task<bool> SyncSubmodules(ILocalRepositoryModel repository, IProgress<string> progress);
59+
Task<bool> SyncSubmodules(ILocalRepositoryModel repository, Action<string> progress);
6060

6161
/// <summary>
6262
/// Calculates the name of a local branch for a pull request avoiding clashes with existing branches.

0 commit comments

Comments
 (0)