From 4da2f0e64f67c7ff5f5af3899eb1c9c0ab888f5a Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Mon, 3 Jun 2024 22:29:31 +1000 Subject: [PATCH] Return `Url` in `GhApiClient::has_release_artifact` Signed-off-by: Jiahao XU --- crates/binstalk-git-repo-api/src/gh_api_client.rs | 3 ++- .../src/gh_api_client/release_artifacts.rs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/binstalk-git-repo-api/src/gh_api_client.rs b/crates/binstalk-git-repo-api/src/gh_api_client.rs index af0b2ab2..f7d6a6ef 100644 --- a/crates/binstalk-git-repo-api/src/gh_api_client.rs +++ b/crates/binstalk-git-repo-api/src/gh_api_client.rs @@ -12,6 +12,7 @@ use std::{ use binstalk_downloader::remote; use compact_str::{format_compact, CompactString}; use tokio::sync::OnceCell; +use url::Url; mod common; mod error; @@ -210,7 +211,7 @@ impl GhApiClient { release, artifact_name, }: GhReleaseArtifact, - ) -> Result, GhApiError> { + ) -> Result, GhApiError> { let once_cell = self.0.release_artifacts.get(release.clone()); let res = once_cell .get_or_try_init(|| { diff --git a/crates/binstalk-git-repo-api/src/gh_api_client/release_artifacts.rs b/crates/binstalk-git-repo-api/src/gh_api_client/release_artifacts.rs index 4ff33684..3af455ed 100644 --- a/crates/binstalk-git-repo-api/src/gh_api_client/release_artifacts.rs +++ b/crates/binstalk-git-repo-api/src/gh_api_client/release_artifacts.rs @@ -9,6 +9,7 @@ use std::{ use binstalk_downloader::remote::{self}; use compact_str::{CompactString, ToCompactString}; use serde::Deserialize; +use url::Url; use super::{ common::{issue_graphql_query, issue_restful_api}, @@ -20,7 +21,7 @@ use super::{ #[derive(Eq, Deserialize, Debug)] struct Artifact { name: CompactString, - url: CompactString, + url: Url, } // Manually implement PartialEq and Hash to ensure it will always produce the @@ -59,7 +60,7 @@ pub(super) struct Artifacts { impl Artifacts { /// get url for downloading the artifact using GitHub API (for private repository). - pub(super) fn get_artifact_url(&self, artifact_name: &str) -> Option { + pub(super) fn get_artifact_url(&self, artifact_name: &str) -> Option { self.assets .get(artifact_name) .map(|artifact| artifact.url.clone())