Skip to content

Commit d452661

Browse files
committed
Merge #4498 Work around GitHub API has_wiki defect
2 parents 6dde144 + 288bb40 commit d452661

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ All notable changes to this project will be documented in this file.
2020

2121
- [Docs] Update download count image for Minkowski² (#4474 by: Clayell; reviewed: HebaruSan)
2222
- [Netkan] Fix `x_netkan_epoch` not applied before unreliable server check (#4477 by: HebaruSan)
23-
- [Netkan] Gitea kref (#4494 by: HebaruSan)
23+
- [Netkan] Gitea kref (#4494, #4498 by: HebaruSan)
2424

2525
## v1.36.2 (Politas)
2626

Netkan/Sources/Github/GithubApi.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public GithubApi(IHttpService http, string? oauthToken = null)
5050

5151
public GithubRepo? GetRepo(GithubRef reference)
5252
=> Call($"repos/{reference.Repository}") is string s
53-
? JsonConvert.DeserializeObject<GithubRepo>(s)
53+
? CheckForWiki(reference, JsonConvert.DeserializeObject<GithubRepo>(s))
5454
: null;
5555

5656
public GithubRelease? GetLatestRelease(GithubRef reference, bool? usePrerelease)
@@ -98,6 +98,19 @@ public List<GithubUser> getOrgMembers(GithubUser organization)
9898
: null)
9999
?? new List<GithubUser>();
100100

101+
private GithubRepo? CheckForWiki(GithubRef reference, GithubRepo? repo)
102+
{
103+
if (repo is { HasWiki: true })
104+
{
105+
repo.HasWiki = ActuallyHasWiki(reference);
106+
}
107+
return repo;
108+
}
109+
110+
private bool ActuallyHasWiki(GithubRef reference)
111+
// If no wiki pages have been created, the /wiki route redirects and this is null
112+
=> _http.DownloadText(new Uri($"https://github.com/{reference.Account}/{reference.Project}/wiki")) != null;
113+
101114
/// <summary>
102115
/// Download a URL via the GitHubAPI.
103116
/// Will use a token if we have one.

0 commit comments

Comments
 (0)