This commit is contained in:
Félix Saparelli 2022-02-16 00:14:51 +13:00
parent 4e0ca0c1c3
commit a12e934940
No known key found for this signature in database
GPG key ID: B948C4BAE44FC474
9 changed files with 199 additions and 117 deletions

View file

@ -4,8 +4,8 @@ use log::{debug, info};
use reqwest::Method;
use serde::Serialize;
use crate::{download, remote_exists, Template};
use super::Data;
use crate::{download, remote_exists, Template};
pub struct GhRelease {
url: String,
@ -15,16 +15,18 @@ pub struct GhRelease {
impl super::Fetcher for GhRelease {
async fn new(data: &Data) -> Result<Box<Self>, anyhow::Error> {
// Generate context for URL interpolation
let ctx = Context {
let ctx = Context {
name: &data.name,
repo: data.repo.as_ref().map(|s| &s[..]),
target: &data.target,
target: &data.target,
version: &data.version,
format: data.meta.pkg_fmt.to_string(),
};
debug!("Using context: {:?}", ctx);
Ok(Box::new(Self { url: ctx.render(&data.meta.pkg_url)? }))
Ok(Box::new(Self {
url: ctx.render(&data.meta.pkg_url)?,
}))
}
async fn check(&self) -> Result<bool, anyhow::Error> {
@ -48,4 +50,4 @@ struct Context<'c> {
pub format: String,
}
impl<'c> Template for Context<'c> {}
impl<'c> Template for Context<'c> {}