Skip to content

Commit

Permalink
(maint) Be consistent about Async suffix
Browse files Browse the repository at this point in the history
Almost all of the code in GitReleaseManager uses the Async suffix for
methods that return a Task, but there were a couple that wasn't doing
that.

This commit addresses that by making sure that we are consistent
everywhere.
  • Loading branch information
gep13 committed Aug 24, 2023
1 parent ef29914 commit 500c81e
Show file tree
Hide file tree
Showing 32 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/GitReleaseManager.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static Task<int> ExecuteCommand<TOptions>(TOptions options)
where TOptions : BaseSubOptions
{
var command = _serviceProvider.GetRequiredService<ICommand<TOptions>>();
return command.Execute(options);
return command.ExecuteAsync(options);
}

private static void LogOptions(BaseSubOptions options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task Should_Execute_Command()
_vcsService.AddAssetsAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.AssetPaths).
Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).AddAssetsAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.AssetPaths).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task Should_Execute_Command()
_vcsService.CloseMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CloseMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task Should_Create_Empty_Release()
_vcsService.CreateEmptyReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Name, options.TargetCommitish, options.Prerelease)
.Returns(_release);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CreateEmptyReleaseAsync(options.RepositoryOwner, options.RepositoryName, releaseName, options.TargetCommitish, options.Prerelease).ConfigureAwait(false);
Expand Down Expand Up @@ -72,7 +72,7 @@ public async Task Should_Create_Release_From_Milestone(string name, int logVerbo
_vcsService.CreateReleaseFromMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone, releaseName, options.TargetCommitish, options.AssetPaths, options.Prerelease, options.Template)
.Returns(_release);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CreateReleaseFromMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone, releaseName, options.TargetCommitish, options.AssetPaths, options.Prerelease, options.Template).ConfigureAwait(false);
Expand All @@ -98,7 +98,7 @@ public async Task Should_Create_Release_From_InputFile()
_vcsService.CreateReleaseFromInputFileAsync(options.RepositoryOwner, options.RepositoryName, options.Name, options.InputFilePath, options.TargetCommitish, options.AssetPaths, options.Prerelease)
.Returns(_release);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CreateReleaseFromInputFileAsync(options.RepositoryOwner, options.RepositoryName, options.Name, options.InputFilePath, options.TargetCommitish, options.AssetPaths, options.Prerelease).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task Should_Execute_Command()
_vcsService.DiscardReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).DiscardReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public async Task Should_Execute_Command()
_vcsService.ExportReleasesAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.SkipPrereleases)
.Returns(releaseText);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

var exportFileExists = File.Exists(_fileOutputPath);
Expand Down
4 changes: 2 additions & 2 deletions src/GitReleaseManager.Core.Tests/Commands/InitCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task Should_Execute_Command()
{
var options = new InitSubOptions { TargetDirectory = _targetDirectory };

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

var configFilePath = Path.Combine(_targetDirectory, "GitReleaseManager.yml");
Expand Down Expand Up @@ -70,7 +70,7 @@ public async Task Should_Not_Execute_Command_For_Legacy_FileName()
File.WriteAllText(configFilePath, "s");
var expectedHash = GetHash(configFilePath);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0); // Should this perhaps return 1

var actualHash = GetHash(configFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task Should_Execute_Command()
_vcsService.CreateLabelsAsync(options.RepositoryOwner, options.RepositoryName)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).CreateLabelsAsync(options.RepositoryOwner, options.RepositoryName).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task Should_Execute_Command()
_vcsService.OpenMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).OpenMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task Should_Execute_Command()
_vcsService.PublishReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.TagName)
.Returns(Task.CompletedTask);

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

await _vcsService.Received(1).PublishReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.TagName).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public async Task Should_Execute_Command()
{
var options = new ShowConfigSubOptions();

var result = await _command.Execute(options).ConfigureAwait(false);
var result = await _command.ExecuteAsync(options).ConfigureAwait(false);
result.ShouldBe(0);

_logger.Received(1).Information(Arg.Any<string>(), Arg.Any<string>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public async Task Should_Get_Commits_Count()
_gitHubClient.Repository.Commit.Compare(OWNER, REPOSITORY, BASE, HEAD)
.Returns(Task.FromResult(new CompareResult(null, null, null, null, null, null, null, null, commitsCount, 0, 0, null, null)));

var result = await _gitHubProvider.GetCommitsCount(OWNER, REPOSITORY, BASE, HEAD).ConfigureAwait(false);
var result = await _gitHubProvider.GetCommitsCountAsync(OWNER, REPOSITORY, BASE, HEAD).ConfigureAwait(false);
result.ShouldBe(commitsCount);

await _gitHubClient.Repository.Commit.Received(1).Compare(OWNER, REPOSITORY, BASE, HEAD).ConfigureAwait(false);
Expand All @@ -173,7 +173,7 @@ public async Task Should_Get_Commits_Count_Zero_If_No_Commits_Found()
_gitHubClient.Repository.Commit.Compare(OWNER, REPOSITORY, BASE, HEAD)
.Returns(Task.FromException<CompareResult>(_notFoundException));

var result = await _gitHubProvider.GetCommitsCount(OWNER, REPOSITORY, BASE, HEAD).ConfigureAwait(false);
var result = await _gitHubProvider.GetCommitsCountAsync(OWNER, REPOSITORY, BASE, HEAD).ConfigureAwait(false);
result.ShouldBe(0);

await _gitHubClient.Repository.Commit.Received(1).Compare(OWNER, REPOSITORY, BASE, HEAD).ConfigureAwait(false);
Expand All @@ -185,7 +185,7 @@ public async Task Should_Throw_An_Exception_On_Getting_Commits_Count()
_gitHubClient.Repository.Commit.Compare(OWNER, REPOSITORY, BASE, HEAD)
.Returns(Task.FromException<CompareResult>(_exception));

var ex = await Should.ThrowAsync<ApiException>(() => _gitHubProvider.GetCommitsCount(OWNER, REPOSITORY, BASE, HEAD)).ConfigureAwait(false);
var ex = await Should.ThrowAsync<ApiException>(() => _gitHubProvider.GetCommitsCountAsync(OWNER, REPOSITORY, BASE, HEAD)).ConfigureAwait(false);
ex.Message.ShouldContain(_exception.Message);
ex.InnerException.ShouldBeSameAs(_exception);
}
Expand Down
24 changes: 12 additions & 12 deletions src/GitReleaseManager.Core.Tests/VcsServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public async Task Should_Create_Release_From_Milestone()
{
var release = new Release();

_releaseNotesBuilder.BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
_releaseNotesBuilder.BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
.Returns(Task.FromResult(RELEASE_NOTES));

_vcsProvider.GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE)
Expand All @@ -310,7 +310,7 @@ public async Task Should_Create_Release_From_Milestone()
var result = await _vcsService.CreateReleaseFromMilestoneAsync(OWNER, REPOSITORY, MILESTONE_TITLE, MILESTONE_TITLE, null, null, false, null).ConfigureAwait(false);
result.ShouldBeSameAs(release);

await _releaseNotesBuilder.Received(1).BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
await _releaseNotesBuilder.Received(1).BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
await _vcsProvider.Received(1).GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE).ConfigureAwait(false);
await _vcsProvider.Received(1).CreateReleaseAsync(OWNER, REPOSITORY, Arg.Is<Release>(o =>
o.Body == RELEASE_NOTES &&
Expand All @@ -328,7 +328,7 @@ public async Task Should_Create_Release_From_Milestone_With_Assets()

var assetsCount = _assets.Count;

_releaseNotesBuilder.BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
_releaseNotesBuilder.BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
.Returns(Task.FromResult(RELEASE_NOTES));

_vcsProvider.GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE)
Expand All @@ -349,7 +349,7 @@ public async Task Should_Create_Release_From_Milestone_With_Assets()
).ConfigureAwait(false);
result.ShouldBeSameAs(release);

await _releaseNotesBuilder.Received(1).BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
await _releaseNotesBuilder.Received(1).BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
await _vcsProvider.Received(1).GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE).ConfigureAwait(false);
await _vcsProvider.Received(1).CreateReleaseAsync(OWNER, REPOSITORY, Arg.Is<Release>(o =>
o.Body == RELEASE_NOTES &&
Expand All @@ -365,7 +365,7 @@ public async Task Should_Create_Release_From_Milestone_Using_Template_File()
{
var release = new Release();

_releaseNotesBuilder.BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, _releaseNotesTemplate)
_releaseNotesBuilder.BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, _releaseNotesTemplate)
.Returns(Task.FromResult(RELEASE_NOTES));

_vcsProvider.GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE)
Expand All @@ -377,7 +377,7 @@ public async Task Should_Create_Release_From_Milestone_Using_Template_File()
var result = await _vcsService.CreateReleaseFromMilestoneAsync(OWNER, REPOSITORY, MILESTONE_TITLE, MILESTONE_TITLE, null, null, false, _releaseNotesTemplateFilePath).ConfigureAwait(false);
result.ShouldBeSameAs(release);

await _releaseNotesBuilder.Received(1).BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, _releaseNotesTemplate).ConfigureAwait(false);
await _releaseNotesBuilder.Received(1).BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, _releaseNotesTemplate).ConfigureAwait(false);
await _vcsProvider.Received(1).GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE).ConfigureAwait(false);
await _vcsProvider.Received(1).CreateReleaseAsync(OWNER, REPOSITORY, Arg.Is<Release>(o =>
o.Body == RELEASE_NOTES &&
Expand All @@ -397,7 +397,7 @@ public async Task Should_Throw_Exception_On_Creating_Release_With_Empty_Template

await Should.ThrowAsync<ArgumentException>(() => _vcsService.CreateReleaseFromMilestoneAsync(OWNER, REPOSITORY, MILESTONE_TITLE, MILESTONE_TITLE, null, null, false, _releaseNotesEmptyTemplateFilePath)).ConfigureAwait(false);

await _releaseNotesBuilder.DidNotReceive().BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, Arg.Any<string>()).ConfigureAwait(false);
await _releaseNotesBuilder.DidNotReceive().BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, Arg.Any<string>()).ConfigureAwait(false);
}

[Test]
Expand All @@ -414,7 +414,7 @@ public async Task Should_Throw_Exception_On_Creating_Release_With_Invalid_Templa
ex.Message.ShouldContain(invalidReleaseNotesTemplateFilePath);
ex.FileName.ShouldBe(fileName);

await _releaseNotesBuilder.DidNotReceive().BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, Arg.Any<string>()).ConfigureAwait(false);
await _releaseNotesBuilder.DidNotReceive().BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, Arg.Any<string>()).ConfigureAwait(false);
}

[TestCase(true, false)]
Expand All @@ -426,7 +426,7 @@ public async Task Should_Update_Published_Release_On_Creating_Release_From_Miles

_configuration.Create.AllowUpdateToPublishedRelease = updatePublishedRelease;

_releaseNotesBuilder.BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
_releaseNotesBuilder.BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
.Returns(Task.FromResult(RELEASE_NOTES));

_vcsProvider.GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE)
Expand All @@ -438,7 +438,7 @@ public async Task Should_Update_Published_Release_On_Creating_Release_From_Miles
var result = await _vcsService.CreateReleaseFromMilestoneAsync(OWNER, REPOSITORY, MILESTONE_TITLE, MILESTONE_TITLE, null, null, false, null).ConfigureAwait(false);
result.ShouldBeSameAs(release);

await _releaseNotesBuilder.Received(1).BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
await _releaseNotesBuilder.Received(1).BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
await _vcsProvider.Received(1).GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE).ConfigureAwait(false);
await _vcsProvider.Received(1).UpdateReleaseAsync(OWNER, REPOSITORY, release).ConfigureAwait(false);

Expand All @@ -454,7 +454,7 @@ public async Task Should_Throw_Exception_While_Updating_Published_Release_On_Cre

_configuration.Create.AllowUpdateToPublishedRelease = false;

_releaseNotesBuilder.BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
_releaseNotesBuilder.BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME)
.Returns(Task.FromResult(RELEASE_NOTES));

_vcsProvider.GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE)
Expand All @@ -463,7 +463,7 @@ public async Task Should_Throw_Exception_While_Updating_Published_Release_On_Cre
var ex = await Should.ThrowAsync<InvalidOperationException>(() => _vcsService.CreateReleaseFromMilestoneAsync(OWNER, REPOSITORY, MILESTONE_TITLE, MILESTONE_TITLE, null, null, false, null)).ConfigureAwait(false);
ex.Message.ShouldBe($"Release with tag '{MILESTONE_TITLE}' not in draft state, so not updating");

await _releaseNotesBuilder.Received(1).BuildReleaseNotes(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
await _releaseNotesBuilder.Received(1).BuildReleaseNotesAsync(OWNER, REPOSITORY, MILESTONE_TITLE, ReleaseTemplates.DEFAULT_NAME).ConfigureAwait(false);
await _vcsProvider.Received(1).GetReleaseAsync(OWNER, REPOSITORY, MILESTONE_TITLE).ConfigureAwait(false);
}

Expand Down
2 changes: 1 addition & 1 deletion src/GitReleaseManager.Core/Commands/AddAssetsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public AddAssetsCommand(IVcsService vcsService, ILogger logger)
_logger = logger;
}

public async Task<int> Execute(AddAssetSubOptions options)
public async Task<int> ExecuteAsync(AddAssetSubOptions options)
{
_logger.Information("Uploading assets");
await _vcsService.AddAssetsAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.AssetPaths).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion src/GitReleaseManager.Core/Commands/CloseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public CloseCommand(IVcsService vcsService, ILogger logger)
_logger = logger;
}

public async Task<int> Execute(CloseSubOptions options)
public async Task<int> ExecuteAsync(CloseSubOptions options)
{
_logger.Information("Closing milestone {Milestone}", options.Milestone);
await _vcsService.CloseMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion src/GitReleaseManager.Core/Commands/CreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public CreateCommand(IVcsService vcsService, ILogger logger)
_logger = logger;
}

public async Task<int> Execute(CreateSubOptions options)
public async Task<int> ExecuteAsync(CreateSubOptions options)
{
_logger.Information("Creating release...");

Expand Down
2 changes: 1 addition & 1 deletion src/GitReleaseManager.Core/Commands/DiscardCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public DiscardCommand(IVcsService vcsService, ILogger logger)
_logger = logger;
}

public async Task<int> Execute(DiscardSubOptions options)
public async Task<int> ExecuteAsync(DiscardSubOptions options)
{
_logger.Information("Discarding release {Milestone}", options.Milestone);
await _vcsService.DiscardReleaseAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
Expand Down
Loading

0 comments on commit 500c81e

Please sign in to comment.