Skip to content

Commit

Permalink
A few small fixes
Browse files Browse the repository at this point in the history
- build_variable should default to `true`
- fetch from upstream if git dir exists
- remove trailing '/' from URLs
  • Loading branch information
cmyr committed Oct 24, 2024
1 parent 2a131a4 commit 8da95c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ use crate::error::BadConfig;
pub struct Config {
pub sources: Vec<String>,
pub family_name: Option<String>,
#[serde(default)]
#[serde(default = "true_")]
pub build_variable: bool,
#[serde(default)]
pub axis_order: Vec<Tag>,
}

fn true_() -> bool {
true
}

impl Config {
/// Parse and return a config.yaml file for the provided font source
pub fn load(config_path: &Path) -> Result<Self, BadConfig> {
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ mod repo_info;

pub use args::Args;
pub use config::Config;
pub use error::{BadConfig, LoadRepoError};
use error::{Error, GitFail, MetadataError, UnwrapOrDie};
pub use error::{BadConfig, Error, GitFail, LoadRepoError};
use error::{MetadataError, UnwrapOrDie};
use metadata::Metadata;
pub use repo_info::RepoInfo;

Expand Down Expand Up @@ -329,6 +329,8 @@ fn config_files_from_local_checkout(
local_repo_dir: &Path,
) -> Result<Vec<PathBuf>, ConfigFetchIssue> {
if local_repo_dir.exists() {
// try fetch; but failure is okay
let _ = fetch_latest(local_repo_dir);
// should we always fetch? idk
} else {
std::fs::create_dir_all(local_repo_dir).unwrap();
Expand Down
1 change: 1 addition & 0 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl FromStr for Metadata {
let repo_url = s
.find(REPO_KEY)
.and_then(|pos| extract_litstr(&s[pos + REPO_KEY.len()..]))
.map(|s| s.trim_end_matches('/')) // trailing / is not meaningful for a url
.filter(|s| !s.is_empty())
.map(str::to_owned);
Ok(Metadata { name, repo_url })
Expand Down

0 comments on commit 8da95c5

Please sign in to comment.