mirror of
https://seed.radicle.dev/rad:zwTxygwuz5LDGBq255RA2CbNGrz8.git
synced 2026-10-18 19:30:29 +08:00
refactor: use ergo module for run commands
Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
@@ -363,4 +363,7 @@ enum CibToolError {
|
||||
|
||||
#[error(transparent)]
|
||||
Event(#[from] cibtoolcmd::EventError),
|
||||
|
||||
#[error(transparent)]
|
||||
Run(#[from] cibtoolcmd::RunError),
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user