refactor<Version>: check latest release from api.github.com instead

This commit is contained in:
leo 2021-11-15 14:23:45 +08:00
parent dcf53c31cc
commit 18f176a66b

View file

@ -52,13 +52,13 @@ namespace SourceGit.Models {
try { try {
#if NET6_0_OR_GREATER #if NET6_0_OR_GREATER
var req = new HttpClient(); var req = new HttpClient();
var rsp = await req.GetAsync("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest"); var rsp = await req.GetAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest");
rsp.EnsureSuccessStatusCode(); rsp.EnsureSuccessStatusCode();
var raw = await rsp.Content.ReadAsStringAsync(); var raw = await rsp.Content.ReadAsStringAsync();
#else #else
var web = new WebClient() { Encoding = Encoding.UTF8 }; var web = new WebClient() { Encoding = Encoding.UTF8 };
var raw = await web.DownloadStringTaskAsync("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest"); var raw = await web.DownloadStringTaskAsync("https://api.github.com/repos/sourcegit-scm/sourcegit/releases/latest");
#endif #endif
var ver = JsonSerializer.Deserialize<Version>(raw); var ver = JsonSerializer.Deserialize<Version>(raw);
var cur = Assembly.GetExecutingAssembly().GetName().Version; var cur = Assembly.GetExecutingAssembly().GetName().Version;