From b614658346257fc0efbc9cda0b3b3087bd3307aa Mon Sep 17 00:00:00 2001 From: Future Date: Thu, 11 Apr 2024 13:08:10 +0200 Subject: [PATCH] maint: handle missing tag_name from github's JSON reply --- src/github.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/github.rs b/src/github.rs index bf33de5..54907e5 100644 --- a/src/github.rs +++ b/src/github.rs @@ -10,8 +10,16 @@ pub async fn latest_tag(owner: &str, repo: &str) -> String { ) .await .unwrap(); + let github_json: serde_json::Value = serde_json::from_str(&github_body).unwrap(); - github_json["tag_name"].to_string().replace('"', "") + + if let Some(tag_name) = github_json.get("tag_name") { + if let Some(tag_name_str) = tag_name.as_str() { + return tag_name_str.to_string().replace('"', ""); + } + } + + "0.0.0".to_string() } pub async fn latest_version(owner: &str, repo: &str) -> Version {