diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-03-11 11:48:20 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-03-11 11:48:20 +0100 |
commit | c5557bf6ea8f4f9c81fe30c6518f7784da777865 (patch) | |
tree | 8d4a5e9f3069af87827a12193f350bbe96fa2b18 | |
parent | 5ca0dbdf1b13eda96a074d0a2d29dffcb5e60b25 (diff) | |
parent | 7a77343ec3ddb99fbbc4b46d2dd6b0dce6c80d60 (diff) |
Merge branch 'misc'
-rw-r--r-- | src/cli.rs | 1 | ||||
-rw-r--r-- | src/commands/build.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 78 | ||||
-rw-r--r-- | src/schema.rs | 22 |
4 files changed, 63 insertions, 40 deletions
@@ -695,6 +695,7 @@ pub fn cli<'a>() -> App<'a> { .subcommand(App::new("release") .version(crate_version!()) + .about("Manage artifact releases") .subcommand(App::new("rm") .version(crate_version!()) .about("Remove release artifacts") diff --git a/src/commands/build.rs b/src/commands/build.rs index 81077d4..bbaa83f 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -88,7 +88,7 @@ pub async fn build( return Err(anyhow!( "Requested build image {} is not in the configured images", image_name )) - .with_context(|| anyhow!("Available images: {:?}", config.docker().images())) + .with_context(|| anyhow!("Available images: {}", config.docker().images().iter().join(", "))) .with_context(|| anyhow!("Image present verification failed")) .map_err(Error::from); } diff --git a/src/main.rs b/src/main.rs index 1aaaefb..ea06a7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,9 +52,11 @@ use std::path::PathBuf; use anyhow::anyhow; use anyhow::Context; +use anyhow::Error; use anyhow::Result; use clap::ArgMatches; use logcrate::debug; +use logcrate::error; use rand as _; // Required to make lints happy use aquamarine as _; // doc-helper crate use funty as _; // doc-helper crate @@ -88,7 +90,13 @@ async fn main() -> Result<()> { let app = cli::cli(); let cli = app.get_matches(); - let repo = git2::Repository::discover(PathBuf::from("."))?; + let repo = git2::Repository::discover(PathBuf::from(".")) + .map_err(|e| match e.code() { + git2::ErrorCode::NotFound => anyhow!("Failed to load the git repository from ./."), + _ => Error::from(e), + }) + .context("Loading the git repository") + .context("Butido must be executed within the package repository")?; let repo_path = repo .workdir() .ok_or_else(|| anyhow!("Not a repository with working directory. Cannot do my job!"))?; @@ -125,7 +133,8 @@ async fn main() -> Result<()> { let load_repo = || -> Result<Repository> { let bar = progressbars.bar(); - let repo = Repository::load(&repo_path, &bar)?; + let repo = Repository::load(&repo_path, &bar) + .context("Loading the repository")?; bar.finish_with_message("Repository loading finished"); Ok(repo) }; @@ -148,67 +157,102 @@ async fn main() -> Result<()> { repo, &repo_path, ) - .await? + .await + .context("build command failed")? } Some(("what-depends", matches)) => { let repo = load_repo()?; - crate::commands::what_depends(matches, &config, repo).await? + crate::commands::what_depends(matches, &config, repo) + .await + .context("what-depends command failed")? } Some(("dependencies-of", matches)) => { let repo = load_repo()?; - crate::commands::dependencies_of(matches, &config, repo).await? + crate::commands::dependencies_of(matches, &config, repo) + .await + .context("dependencies-of command failed")? } Some(("versions-of", matches)) => { let repo = load_repo()?; - crate::commands::versions_of(matches, repo).await? + crate::commands::versions_of(matches, repo) + .await + .context("versions-of command failed")? } Some(("env-of", matches)) => { let repo = load_repo()?; - crate::commands::env_of(matches, repo).await? + crate::commands::env_of(matches, repo) + .await + .context("env-of command failed")? } Some(("find-artifact", matches)) => { let repo = load_repo()?; let conn = crate::db::establish_connection(db_connection_config)?; - crate::commands::find_artifact(matches, &config, progressbars, repo, conn).await? + crate::commands::find_artifact(matches, &config, progressbars, repo, conn) + .await + .context("find-artifact command failed")? } Some(("find-pkg", matches)) => { let repo = load_repo()?; - crate::commands::find_pkg(matches, &config, repo).await? + crate::commands::find_pkg(matches, &config, repo) + .await + .context("find-pkg command failed")? } Some(("source", matches)) => { let repo = load_repo()?; - crate::commands::source(matches, &config, repo, progressbars).await? + crate::commands::source(matches, &config, repo, progressbars) + .await + .context("source command failed")? } Some(("release", matches)) => { - crate::commands::release(db_connection_config, &config, matches).await? + crate::commands::release(db_connection_config, &config, matches) + .await + .context("release command failed")? } Some(("lint", matches)) => { let repo = load_repo()?; - crate::commands::lint(&repo_path, matches, progressbars, &config, repo).await? + crate::commands::lint(&repo_path, matches, progressbars, &config, repo) + .await + .context("lint command failed")? } Some(("tree-of", matches)) => { let repo = load_repo()?; - crate::commands::tree_of(matches, repo, progressbars).await? + crate::commands::tree_of(matches, repo, progressbars) + .await + .context("tree-of command failed")? } Some(("metrics", _)) => { let repo = load_repo()?; let conn = crate::db::establish_connection(db_connection_config)?; - crate::commands::metrics(&repo_path, &config, repo, conn).await? + crate::commands::metrics(&repo_path, &config, repo, conn) + .await + .context("metrics command failed")? } - Some(("endpoint", matches)) => crate::commands::endpoint(matches, &config, progressbars).await?, - Some((other, _)) => return Err(anyhow!("Unknown subcommand: {}", other)), - None => return Err(anyhow!("No subcommand")), + Some(("endpoint", matches)) => { + crate::commands::endpoint(matches, &config, progressbars) + .await + .context("endpoint command failed")? + }, + Some((other, _)) => { + error!("Unknown subcommand: {}", other); + error!("Use --help to find available subcommands"); + return Err(anyhow!("Unknown subcommand: {}", other)) + }, + None => { + error!("No subcommand."); + error!("Use --help to find available subcommands"); + return Err(anyhow!("No subcommand")) + }, } Ok(()) diff --git a/src/schema.rs b/src/schema.rs index 2bcb927..2e2895b 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -44,22 +44,6 @@ table! { } table! { - job_input_artifacts (id) { - id -> Int4, - job_id -> Int4, - artifact_id -> Int4, - } -} - -table! { - job_output_artifacts (id) { - id -> Int4, - job_id -> Int4, - artifact_id -> Int4, - } -} - -table! { jobs (id) { id -> Int4, submit_id -> Int4, @@ -119,10 +103,6 @@ table! { joinable!(artifacts -> jobs (job_id)); joinable!(job_envs -> envvars (env_id)); joinable!(job_envs -> jobs (job_id)); -joinable!(job_input_artifacts -> artifacts (artifact_id)); -joinable!(job_input_artifacts -> jobs (job_id)); -joinable!(job_output_artifacts -> artifacts (artifact_id)); -joinable!(job_output_artifacts -> jobs (job_id)); joinable!(jobs -> endpoints (endpoint_id)); joinable!(jobs -> images (image_id)); joinable!(jobs -> packages (package_id)); @@ -142,8 +122,6 @@ allow_tables_to_appear_in_same_query!( githashes, images, job_envs, - job_input_artifacts, - job_output_artifacts, jobs, packages, release_stores, |