v0.4.1 : Phase 1 complete (17/17) - dashboard TUI (#33), favoris/notes/tags (#39), profils d'environnement (#40), completions dynamiques + man pages (#41), packaging officiel + CI (#42), self-update Gitea, state v3, 212 tests
release / linux (push) Failing after 23s
release / windows (push) Canceled after 0s
release / macos (push) Canceled after 0s

This commit is contained in:
2026-08-17 10:50:13 -04:00
parent 4f4cd034b2
commit 56732d672b
93 changed files with 9412 additions and 1270 deletions
+15 -6
View File
@@ -150,19 +150,28 @@ fn github_auth_header() -> Option<String> {
}
pub fn latest_release(repo: &str) -> Result<GhRelease> {
match latest_release_api(repo) {
latest_release_with_base(repo, None)
}
/// Resolve the latest release, with an optional API base URL override
/// (e.g. https://git.dracodev.net/api/v1 for a Gitea instance).
pub fn latest_release_with_base(repo: &str, api_base: Option<&str>) -> Result<GhRelease> {
let github = api_base.is_none() || api_base == Some("https://api.github.com");
match latest_release_api(repo, api_base) {
Ok(release) => Ok(release),
Err(e) if format!("{e:#}").contains("rate limit") => {
// The API is rate limited (60 unauthenticated requests/hour):
// fall back to the GitHub web pages, which are not limited.
Err(e) if github && format!("{e:#}").contains("rate limit") => {
// The GitHub API is rate limited (60 unauthenticated
// requests/hour): fall back to the GitHub web pages, which are
// not limited. (Gitea has no equivalent web fallback.)
latest_release_web(repo)
}
Err(e) => Err(e),
}
}
fn latest_release_api(repo: &str) -> Result<GhRelease> {
let url = format!("https://api.github.com/repos/{repo}/releases/latest");
fn latest_release_api(repo: &str, api_base: Option<&str>) -> Result<GhRelease> {
let base = api_base.unwrap_or("https://api.github.com");
let url = format!("{base}/repos/{repo}/releases/latest");
let mut req = ureq::get(&url).set("User-Agent", USER_AGENT);
if let Some(auth) = github_auth_header() {
req = req.set("Authorization", &auth);