Skip to content

Commit 288bb40

Browse files
committed
Work around GitHub API has_wiki defect
1 parent 6dde144 commit 288bb40

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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)