From 7d9fcd94d4c4e4972c895bb77e16259389bf9a2c Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Fri, 10 Nov 2023 20:23:41 +0000 Subject: [PATCH] (maint) Update wording and handling of culture --- src/GitReleaseManager.Core/Commands/AddAssetsCommand.cs | 2 +- src/GitReleaseManager.Core/Commands/ExportCommand.cs | 6 +++--- src/GitReleaseManager.Core/Commands/LabelCommand.cs | 2 +- .../Extensions/MilestoneExtensions.cs | 4 ++-- .../MappingProfiles/GitHubProfile.cs | 3 ++- .../ReleaseNotes/ReleaseNotesBuilder.cs | 2 +- src/GitReleaseManager.Core/VcsService.cs | 8 ++++---- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/GitReleaseManager.Core/Commands/AddAssetsCommand.cs b/src/GitReleaseManager.Core/Commands/AddAssetsCommand.cs index 8765f18e..d8531c63 100644 --- a/src/GitReleaseManager.Core/Commands/AddAssetsCommand.cs +++ b/src/GitReleaseManager.Core/Commands/AddAssetsCommand.cs @@ -21,7 +21,7 @@ public async Task ExecuteAsync(AddAssetSubOptions options) if (vcsOptions?.Provider == Model.VcsProvider.GitLab) { - _logger.Error("The addasset command is currently not supported when targetting GitLab."); + _logger.Error("The 'addasset' command is currently not supported when targeting GitLab."); return 1; } diff --git a/src/GitReleaseManager.Core/Commands/ExportCommand.cs b/src/GitReleaseManager.Core/Commands/ExportCommand.cs index 011ae3cd..9cde1f8e 100644 --- a/src/GitReleaseManager.Core/Commands/ExportCommand.cs +++ b/src/GitReleaseManager.Core/Commands/ExportCommand.cs @@ -18,13 +18,13 @@ public ExportCommand(IVcsService vcsService, ILogger logger) public async Task ExecuteAsync(ExportSubOptions options) { - if (string.IsNullOrEmpty(options.TagName)) + if (string.IsNullOrWhiteSpace(options.TagName)) { - _logger.Information("Exporting all releases"); + _logger.Information("Exporting all releases."); } else { - _logger.Information("Exporting release {TagName}", options.TagName); + _logger.Information("Exporting release {TagName}.", options.TagName); } var releasesContent = await _vcsService.ExportReleasesAsync(options.RepositoryOwner, options.RepositoryName, options.TagName, options.SkipPrereleases).ConfigureAwait(false); diff --git a/src/GitReleaseManager.Core/Commands/LabelCommand.cs b/src/GitReleaseManager.Core/Commands/LabelCommand.cs index 1a766b90..63786d6b 100644 --- a/src/GitReleaseManager.Core/Commands/LabelCommand.cs +++ b/src/GitReleaseManager.Core/Commands/LabelCommand.cs @@ -21,7 +21,7 @@ public async Task ExecuteAsync(LabelSubOptions options) if (vcsOptions?.Provider == Model.VcsProvider.GitLab) { - _logger.Error("The label command is currently not supported when targetting GitLab."); + _logger.Error("The label command is currently not supported when targeting GitLab."); return 1; } diff --git a/src/GitReleaseManager.Core/Extensions/MilestoneExtensions.cs b/src/GitReleaseManager.Core/Extensions/MilestoneExtensions.cs index 19e29e6c..f919a6ad 100644 --- a/src/GitReleaseManager.Core/Extensions/MilestoneExtensions.cs +++ b/src/GitReleaseManager.Core/Extensions/MilestoneExtensions.cs @@ -17,13 +17,13 @@ public static Version Version(this Octokit.Milestone ver) var nameWithoutPrerelease = ver.Title.Split('-')[0]; if (nameWithoutPrerelease.StartsWith("v", StringComparison.OrdinalIgnoreCase)) { - _logger.Debug("Removing version prefix from {Name}", ver.Title); + _logger.Debug("Removing version prefix from {Name}.", ver.Title); nameWithoutPrerelease = nameWithoutPrerelease.Remove(0, 1); } if (!System.Version.TryParse(nameWithoutPrerelease, out Version parsedVersion)) { - _logger.Warning("No valid version was found on {Title}", ver.Title); + _logger.Warning("No valid version was found on {Title}.", ver.Title); return new Version(0, 0); } diff --git a/src/GitReleaseManager.Core/MappingProfiles/GitHubProfile.cs b/src/GitReleaseManager.Core/MappingProfiles/GitHubProfile.cs index afa1f072..dff999dc 100644 --- a/src/GitReleaseManager.Core/MappingProfiles/GitHubProfile.cs +++ b/src/GitReleaseManager.Core/MappingProfiles/GitHubProfile.cs @@ -1,3 +1,4 @@ +using System; using AutoMapper; using GitReleaseManager.Core.Extensions; @@ -10,7 +11,7 @@ public GitHubProfile() CreateMap() .ForMember(dest => dest.PublicNumber, act => act.MapFrom(src => src.Number)) .ForMember(dest => dest.InternalNumber, act => act.MapFrom(src => src.Id)) - .ForMember(dest => dest.IsPullRequest, act => act.MapFrom(src => src.HtmlUrl.Contains("/pull/"))) + .ForMember(dest => dest.IsPullRequest, act => act.MapFrom(src => src.HtmlUrl.IndexOf("/pull/", StringComparison.OrdinalIgnoreCase) >= 0)) .ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); diff --git a/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs b/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs index 1ee2b426..79273145 100644 --- a/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs +++ b/src/GitReleaseManager.Core/ReleaseNotes/ReleaseNotesBuilder.cs @@ -60,7 +60,7 @@ public async Task BuildReleaseNotesAsync(string user, string repository, if (issues.Count == 0) { - var logMessage = string.Format(CultureInfo.InvariantCulture, "No closed issues have been found for milestone {0}, or all assigned issues are meant to be excluded from release notes, aborting creation of release.", _milestoneTitle); + var logMessage = string.Format(CultureInfo.CurrentCulture, "No closed issues have been found for milestone {0}, or all assigned issues are meant to be excluded from release notes, aborting release creation.", _milestoneTitle); throw new InvalidOperationException(logMessage); } diff --git a/src/GitReleaseManager.Core/VcsService.cs b/src/GitReleaseManager.Core/VcsService.cs index c98ec420..601a20b3 100644 --- a/src/GitReleaseManager.Core/VcsService.cs +++ b/src/GitReleaseManager.Core/VcsService.cs @@ -142,7 +142,7 @@ private async Task AddAssetsAsync(string owner, string repository, string tagNam { if (!File.Exists(asset)) { - var message = string.Format(CultureInfo.InvariantCulture, "Requested asset to be uploaded doesn't exist: {0}", asset); + var message = string.Format(CultureInfo.CurrentCulture, "The requested asset to be uploaded doesn't exist: {0}", asset); throw new FileNotFoundException(message); } @@ -155,7 +155,7 @@ private async Task AddAssetsAsync(string owner, string repository, string tagNam if (_vcsProvider is GitLabProvider) { - _logger.Error("Deleting of assets is not currently supported when targetting GitLab."); + _logger.Error("Deleting assets is not currently supported when targeting GitLab."); } else { @@ -186,7 +186,7 @@ private async Task AddAssetsAsync(string owner, string repository, string tagNam if (!release.Body.Contains(_configuration.Create.ShaSectionHeading)) { _logger.Debug("Creating SHA section header"); - stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, "### {0}", _configuration.Create.ShaSectionHeading)); + stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "### {0}", _configuration.Create.ShaSectionHeading).AppendLine(); } foreach (var asset in assets) @@ -405,7 +405,7 @@ private async Task AddIssueCommentsAsync(string owner, string repository, Milest } catch (ForbiddenException) { - _logger.Error("Unable to add comment to issue #{IssueNumber}. Insufficient permissions.", issue.PublicNumber); + _logger.Error("Unable to add a comment to issue #{IssueNumber}. Insufficient permissions.", issue.PublicNumber); break; } }