From 2d47e479a5e48a575db3ca9998653c0435419440 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 11 Apr 2018 19:55:01 -0400 Subject: fix draft releases being detected as update candidates --- docs/release-notes.md | 1 + src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs | 2 +- src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs | 4 ++++ src/SMAPI.Web/appsettings.json | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index a5bd205f..e68720da 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -22,6 +22,7 @@ * Fixed mod not loaded if it has an optional dependency that's loaded but skipped. * Fixed mod update alerts not shown if one mod has an invalid remote version. * Fixed SMAPI update alerts linking to the GitHub repository instead of [smapi.io](https://smapi.io). + * Fixed SMAPI update alerts for draft releases. * Fixed error when two content packs use different capitalisation for the same required mod ID. * Fixed rare crash if the game duplicates an item. diff --git a/src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs b/src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs index 4abe0737..2cfc6903 100644 --- a/src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs +++ b/src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs @@ -59,7 +59,7 @@ namespace StardewModdingAPI.Web.Framework.Clients.GitHub GitRelease[] results = await this.Client .GetAsync(string.Format(this.AnyReleaseUrlFormat, repo)) .AsArray(); - return results.FirstOrDefault(); + return results.FirstOrDefault(p => !p.IsDraft); } return await this.Client diff --git a/src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs b/src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs index 827374fb..d0db5297 100644 --- a/src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs +++ b/src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs @@ -19,6 +19,10 @@ namespace StardewModdingAPI.Web.Framework.Clients.GitHub /// The Markdown description for the release. public string Body { get; set; } + /// Whether this is a draft version. + [JsonProperty("draft")] + public bool IsDraft { get; set; } + /// Whether this is a prerelease version. [JsonProperty("prerelease")] public bool IsPrerelease { get; set; } diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json index 03ca31ed..095707a8 100644 --- a/src/SMAPI.Web/appsettings.json +++ b/src/SMAPI.Web/appsettings.json @@ -25,7 +25,7 @@ "GitHubBaseUrl": "https://api.github.com", "GitHubStableReleaseUrlFormat": "repos/{0}/releases/latest", - "GitHubAnyReleaseUrlFormat": "repos/{0}/releases?per_page=1", + "GitHubAnyReleaseUrlFormat": "repos/{0}/releases?per_page=2", // allow for draft release (only visible if GitHub repo is owned by same account as the update check credentials) "GitHubAcceptHeader": "application/vnd.github.v3+json", "GitHubUsername": null, // see top note "GitHubPassword": null, // see top note -- cgit