fix fetchFromGitHub with githubBase

This commit is contained in:
figsoda 2022-12-31 13:48:43 -05:00
parent 1e2c7c24c4
commit 409ae12a11
2 changed files with 5 additions and 3 deletions

View File

@ -8,6 +8,7 @@ use std::{fmt::Write as _, io::Write};
use crate::common::{flake_prefetch, fod_prefetch};
pub trait SimpleFetcher<'a> {
const HOST_KEY: &'static str = "domain";
const NAME: &'static str;
fn host(&'a self) -> &'a Option<String>;
@ -37,7 +38,7 @@ pub trait SimpleFetcher<'a> {
Self::NAME
);
if let Some(host) = self.host() {
write!(expr, r#"domain="{host}""#)?;
write!(expr, r#"{}="{host}""#, Self::HOST_KEY)?;
}
for (key, value) in args {
write!(expr, "{key}={value};")?;
@ -61,8 +62,8 @@ pub trait SimpleFetcher<'a> {
) -> Result<()> {
writeln!(out, "{} {{", Self::NAME)?;
if let Some(domain) = self.host() {
writeln!(out, r#"{indent} domain = "{domain}";"#)?;
if let Some(host) = self.host() {
writeln!(out, r#"{indent} {} = "{host}";"#, Self::HOST_KEY)?;
}
writedoc!(

View File

@ -7,6 +7,7 @@ pub struct FetchFromGitHub(pub Option<String>);
impl_fetcher!(FetchFromGitHub);
impl<'a> SimpleFetcher<'a> for FetchFromGitHub {
const HOST_KEY: &'static str = "githubBase";
const NAME: &'static str = "fetchFromGitHub";
fn host(&'a self) -> &'a Option<String> {