Another autoformat
This commit is contained in:
@@ -334,7 +334,9 @@ mod tests {
|
|||||||
"./test_data/not_real_5.toml",
|
"./test_data/not_real_5.toml",
|
||||||
"./test_data/sample_config.toml",
|
"./test_data/sample_config.toml",
|
||||||
"./test_data/not_real_6.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 load_result = get_config("/home/robert/projects/gt-tool", search_paths)?;
|
||||||
let expected = PartialConfig {
|
let expected = PartialConfig {
|
||||||
project_path: Some(String::from("/home/robert/projects/gt-tool")),
|
project_path: Some(String::from("/home/robert/projects/gt-tool")),
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub(crate) async fn decode_client_error(response: reqwest::Response) -> Result<A
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Placeholder, // TODO: Enumerate error modes
|
Placeholder, // TODO: Enumerate error modes
|
||||||
MissingGiteaUrl, // the gitea URL wasn't specified on the CLI, env, or config file.
|
MissingGiteaUrl, // the gitea URL wasn't specified on the CLI, env, or config file.
|
||||||
MissingRepoFRQN, // either the owner, repo, or both weren't specified in the loaded PartialConfig
|
MissingRepoFRQN, // either the owner, repo, or both weren't specified in the loaded PartialConfig
|
||||||
WrappedConfigErr(config::Error),
|
WrappedConfigErr(config::Error),
|
||||||
|
|||||||
29
src/main.rs
29
src/main.rs
@@ -15,31 +15,34 @@ async fn main() -> Result<(), gt_tool::Error> {
|
|||||||
// TODO: Heuristics to guess project path
|
// TODO: Heuristics to guess project path
|
||||||
// See issue #8: https://git.gelvin.dev/robert/gt-tool/issues/8
|
// See issue #8: https://git.gelvin.dev/robert/gt-tool/issues/8
|
||||||
let pwd = std::env::current_dir()
|
let pwd = std::env::current_dir()
|
||||||
.map_err(|_e| gt_tool::Error::WrappedConfigErr(
|
.map_err(|_e| gt_tool::Error::WrappedConfigErr(gt_tool::config::Error::CouldntReadFile))?;
|
||||||
gt_tool::config::Error::CouldntReadFile
|
|
||||||
))?;
|
|
||||||
let config = gt_tool::config::get_config(
|
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..."),
|
pwd.to_str()
|
||||||
gt_tool::config::default_paths()
|
.expect("I assumed the path can be UTF-8, but that didn't work out..."),
|
||||||
|
gt_tool::config::default_paths(),
|
||||||
)?;
|
)?;
|
||||||
println!("->> Loaded Config: {config:?}");
|
println!("->> Loaded Config: {config:?}");
|
||||||
// arg parser also checks the environment. Prefer CLI/env, then config file.
|
// 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)
|
// Config files split the repo FQRN into "owner" and "repo" (confusing naming, sorry)
|
||||||
// These must be merged back together and passed along.
|
// 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)
|
.ok_or(gt_tool::Error::MissingRepoFRQN)
|
||||||
.and_then(| mut own| {
|
.and_then(|mut own| {
|
||||||
let repo = config.repo.ok_or(gt_tool::Error::MissingRepoFRQN)?;
|
let repo = config.repo.ok_or(gt_tool::Error::MissingRepoFRQN)?;
|
||||||
own.push_str("/");
|
own.push_str("/");
|
||||||
own.push_str(&repo);
|
own.push_str(&repo);
|
||||||
Ok(own)
|
Ok(own)
|
||||||
});
|
});
|
||||||
let repo_fqrn = args.repo
|
let repo_fqrn = args
|
||||||
|
.repo
|
||||||
.ok_or(gt_tool::Error::MissingRepoFRQN)
|
.ok_or(gt_tool::Error::MissingRepoFRQN)
|
||||||
.or(conf_fqrn)?;
|
.or(conf_fqrn)?;
|
||||||
|
|
||||||
|
|
||||||
let mut headers = reqwest::header::HeaderMap::new();
|
let mut headers = reqwest::header::HeaderMap::new();
|
||||||
headers.append(ACCEPT, header::HeaderValue::from_static("application/json"));
|
headers.append(ACCEPT, header::HeaderValue::from_static("application/json"));
|
||||||
|
|
||||||
@@ -121,11 +124,7 @@ async fn main() -> Result<(), gt_tool::Error> {
|
|||||||
}
|
}
|
||||||
for file in files {
|
for file in files {
|
||||||
let _attach_desc = gt_tool::api::release_attachment::create_release_attachment(
|
let _attach_desc = gt_tool::api::release_attachment::create_release_attachment(
|
||||||
&client,
|
&client, &gitea_url, &repo_fqrn, release.id, file,
|
||||||
&gitea_url,
|
|
||||||
&repo_fqrn,
|
|
||||||
release.id,
|
|
||||||
file,
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user