diff --git a/src/config.rs b/src/config.rs index dfe4f94..afbf012 100644 --- a/src/config.rs +++ b/src/config.rs @@ -166,10 +166,10 @@ impl TryFrom<&Table> for PartialConfig { type Error = crate::config::Error; /// Scans properties out of a `toml::Table` to get a PartialConfig. - /// + /// /// `Error::NoSuchProperty` is quietly ignored (mapped to `None`) since it /// isn't an error in this context. - /// + /// /// All other errors are propagated and should be treated as real failures. fn try_from(value: &Table) -> Result { Ok(Self { @@ -315,8 +315,8 @@ mod tests { let load_result = get_config("/some/other/path", search_paths)?; let expected = PartialConfig { project_path: Some(String::from("/some/other/path")), - gitea_url: Some(String::from("fake-url")), - ..PartialConfig::default() + gitea_url: Some(String::from("fake-url")), + ..PartialConfig::default() }; assert_eq!(load_result, expected); Ok(()) @@ -334,7 +334,9 @@ mod tests { "./test_data/not_real_5.toml", "./test_data/sample_config.toml", "./test_data/not_real_6.toml", - ].into_iter().map(PathBuf::from); + ] + .into_iter() + .map(PathBuf::from); let load_result = get_config("/home/robert/projects/gt-tool", search_paths)?; let expected = PartialConfig { project_path: Some(String::from("/home/robert/projects/gt-tool")), diff --git a/src/lib.rs b/src/lib.rs index d14ed47..25c0afd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,7 +20,7 @@ pub(crate) async fn decode_client_error(response: reqwest::Response) -> Result Result<(), gt_tool::Error> { // TODO: Heuristics to guess project path // See issue #8: https://git.gelvin.dev/robert/gt-tool/issues/8 let pwd = std::env::current_dir() - .map_err(|_e| gt_tool::Error::WrappedConfigErr( - gt_tool::config::Error::CouldntReadFile - ))?; + .map_err(|_e| gt_tool::Error::WrappedConfigErr(gt_tool::config::Error::CouldntReadFile))?; let config = gt_tool::config::get_config( - pwd.to_str().expect("I assumed the path can be UTF-8, but that didn't work out..."), - gt_tool::config::default_paths() + pwd.to_str() + .expect("I assumed the path can be UTF-8, but that didn't work out..."), + gt_tool::config::default_paths(), )?; println!("->> Loaded Config: {config:?}"); // arg parser also checks the environment. Prefer CLI/env, then config file. - let gitea_url = args.gitea_url.or(config.gitea_url).ok_or(gt_tool::Error::MissingGiteaUrl)?; + let gitea_url = args + .gitea_url + .or(config.gitea_url) + .ok_or(gt_tool::Error::MissingGiteaUrl)?; // Config files split the repo FQRN into "owner" and "repo" (confusing naming, sorry) // These must be merged back together and passed along. - let conf_fqrn = config.owner + let conf_fqrn = config + .owner .ok_or(gt_tool::Error::MissingRepoFRQN) - .and_then(| mut own| { + .and_then(|mut own| { let repo = config.repo.ok_or(gt_tool::Error::MissingRepoFRQN)?; own.push_str("/"); own.push_str(&repo); Ok(own) }); - let repo_fqrn = args.repo + let repo_fqrn = args + .repo .ok_or(gt_tool::Error::MissingRepoFRQN) .or(conf_fqrn)?; - let mut headers = reqwest::header::HeaderMap::new(); headers.append(ACCEPT, header::HeaderValue::from_static("application/json")); @@ -121,11 +124,7 @@ async fn main() -> Result<(), gt_tool::Error> { } for file in files { let _attach_desc = gt_tool::api::release_attachment::create_release_attachment( - &client, - &gitea_url, - &repo_fqrn, - release.id, - file, + &client, &gitea_url, &repo_fqrn, release.id, file, ) .await?; }