diff --git a/.fallout/build.schema.json b/.fallout/build.schema.json index 8274ca869..fde15dc2b 100644 --- a/.fallout/build.schema.json +++ b/.fallout/build.schema.json @@ -148,6 +148,16 @@ "type": "string", "default": "Secrets must be entered via 'fallout :secrets [profile]'" }, + "NuGetSource": { + "type": "string" + }, + "PublishTo": { + "type": "array", + "description": "Publish only to these named targets (default: all configured PublishTargets)", + "items": { + "type": "string" + } + }, "Solution": { "type": "string", "description": "Path to a solution file that is automatically loaded" diff --git a/src/Fallout.Common/ChangeLog/ChangeLogTasks.cs b/src/Fallout.Common/ChangeLog/ChangeLogTasks.cs index 2d5d0f307..c354b0293 100644 --- a/src/Fallout.Common/ChangeLog/ChangeLogTasks.cs +++ b/src/Fallout.Common/ChangeLog/ChangeLogTasks.cs @@ -21,10 +21,12 @@ public static class ChangelogTasks { public static string GetNuGetReleaseNotes(string changelogFile, GitRepository repository = null) { + AbsolutePath changelogPath = changelogFile; + // URL-encode characters MSBuild treats as command-line/property metacharacters. // Without this, MSBuild's property parser splits on ; (turning a long release note // into multiple bogus arguments) and chokes on stray " in the value. - var changelogSectionNotes = ExtractChangelogSectionNotes(changelogFile) + var changelogSectionNotes = ExtractChangelogSectionNotes(changelogPath) .Select(x => x.Replace("- ", "\u2022 ") .Replace("* ", "\u2022 ") .Replace("+ ", "\u2022 ") @@ -32,10 +34,10 @@ public static string GetNuGetReleaseNotes(string changelogFile, GitRepository re .Replace(",", "%2C") .Replace(";", "%3B")).ToList(); - if (repository.IsGitHubRepository()) + if (repository.IsGitHubRepository() && changelogPath.FileExists()) { changelogSectionNotes.Add(string.Empty); - changelogSectionNotes.Add($"Full changelog at {repository.GetGitHubBrowseUrl(changelogFile)}"); + changelogSectionNotes.Add($"Full changelog at {repository.GetGitHubBrowseUrl(changelogPath, itemType: GitHubItemType.File)}"); } return changelogSectionNotes.JoinNewLine(); diff --git a/tests/Fallout.Common.Tests/ChangelogTasksTest.cs b/tests/Fallout.Common.Tests/ChangelogTasksTest.cs index f7f639681..3f0970f34 100644 --- a/tests/Fallout.Common.Tests/ChangelogTasksTest.cs +++ b/tests/Fallout.Common.Tests/ChangelogTasksTest.cs @@ -4,7 +4,9 @@ using System.Threading.Tasks; using FluentAssertions; using Fallout.Common.ChangeLog; +using Fallout.Common.Git; using Fallout.Common.IO; +using Fallout.Common.Tools.GitHub; using VerifyXunit; using Xunit; @@ -38,6 +40,20 @@ public void Extracting_a_changelog_from_a_non_existing_file_returns_an_empty_col ChangelogTasks.ExtractChangelogSectionNotes(file).Should().BeEmpty(); } + [Fact] + public void Missing_changelog_does_not_add_a_full_changelog_link_to_release_notes() + { + // Arrange + var changelogFile = RootDirectory / "does-not-exist.md"; + var repository = GitRepository.FromLocalDirectory(RootDirectory); + + // Act + string releaseNotes = ChangelogTasks.GetNuGetReleaseNotes(changelogFile, repository); + + // Assert + releaseNotes.Should().BeEmpty(); + } + [Fact] public void GetReleaseSections_ChangelogReferenceFileWithoutReleaseHead_ReturnsEmpty() {