diff --git a/src/bin/cibtool.rs b/src/bin/cibtool.rs index cff3c251..abd34609 100644 --- a/src/bin/cibtool.rs +++ b/src/bin/cibtool.rs @@ -363,4 +363,7 @@ enum CibToolError { #[error(transparent)] Event(#[from] cibtoolcmd::EventError), + + #[error(transparent)] + Run(#[from] cibtoolcmd::RunError), } diff --git a/src/bin/cibtoolcmd/run.rs b/src/bin/cibtoolcmd/run.rs index 4e8936a4..e9bc6310 100644 --- a/src/bin/cibtoolcmd/run.rs +++ b/src/bin/cibtoolcmd/run.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; -use radicle_ci_broker::run::RunBuilder; +use radicle_ci_broker::{ergo, run::RunBuilder}; use radicle_job::JobId; use super::*; @@ -62,9 +62,18 @@ impl Leaf for AddRun { fn run(&self, args: &Args) -> Result<(), CibToolError> { let db = args.open_db()?; - let profile = util::load_profile()?; - let (rid, repo_name) = util::lookup_repo(&profile, &self.repo)?; - let oid = util::oid_from_cli_arg(&profile, rid, &self.commit)?; + let r = ergo::Radicle::new().map_err(RunError::Ergonomic)?; + let repo = r + .repository_by_name(&self.repo) + .map_err(RunError::Ergonomic)?; + let repo_name = r + .project(&repo.id) + .map_err(RunError::Ergonomic)? + .name() + .to_string(); + let oid = r + .resolve_commit(&repo.id, &self.commit) + .map_err(RunError::Ergonomic)?; let ts = self.timestamp.clone().unwrap_or(util::now()?); let whence = Whence::Branch { @@ -74,7 +83,7 @@ impl Leaf for AddRun { }; let mut run = RunBuilder::default() .broker_run_id(RunId::default()) - .repo_id(rid) + .repo_id(repo.id) .repo_name(&repo_name) .whence(whence) .timestamp(ts) @@ -264,3 +273,9 @@ impl Leaf for ListRuns { Ok(()) } } + +#[derive(Debug, thiserror::Error)] +pub enum RunError { + #[error(transparent)] + Ergonomic(#[from] radicle_ci_broker::ergo::ErgoError), +}