Radish alpha
r
rad:z3qg5TKmN83afz2fj9z3fQjU8vaYE
Radicle CI adapter for native CI
Radicle
Git
fix: pass in request to run log
Lars Wirzenius committed 1 year ago
commit 153c4fdcc5c30d9218ebda99f4e87b0c506be012
parent 7e4a761
2 files changed +12 -3
modified src/engine.rs
@@ -77,7 +77,7 @@ impl Engine {
                let repo = req.repo();
                let commit = req.commit();

-
                match self.run_helper(repo, name, commit, Some(branch), None) {
+
                match self.run_helper(repo, name, req.clone(), commit, Some(branch), None) {
                    Ok(true) => success = true,
                    Ok(false) => (),
                    Err(e) => {
@@ -106,7 +106,7 @@ impl Engine {
                let repo = req.repo();
                let commit = req.commit();

-
                match self.run_helper(repo, name, commit, None, Some((*id, title))) {
+
                match self.run_helper(repo, name, req.clone(), commit, None, Some((*id, title))) {
                    Ok(true) => success = true,
                    Ok(false) => (),
                    Err(e) => {
@@ -174,6 +174,7 @@ impl Engine {
        &mut self,
        rid: RepoId,
        name: &str,
+
        req: Request,
        commit: Oid,
        branch: Option<&str>,
        patch: Option<(Oid, &str)>,
@@ -199,6 +200,7 @@ impl Engine {
        // Create and set up the run.
        let mut run = Run::new(&run_dir, &run_log_filename)?;
        run.set_repository(rid, name);
+
        run.set_request(req);
        run.set_commit(commit);
        run.set_storage(storage);
        run.set_timeout(self.config.timeout());
modified src/run.rs
@@ -4,7 +4,7 @@ use std::{
    time::SystemTime,
};

-
use radicle_ci_broker::msg::{Oid, RepoId};
+
use radicle_ci_broker::msg::{Oid, RepoId, Request};

use crate::{
    msg::NativeMessageError,
@@ -29,6 +29,7 @@ pub const RUNSPEC_PATH: &str = ".radicle/native.yaml";
pub struct Run {
    run_log: RunLog,
    rid: Option<RepoId>,
+
    request: Option<Request>,
    repo_name: Option<String>,
    commit: Option<Oid>,
    storage: Option<PathBuf>,
@@ -45,6 +46,7 @@ impl Run {
            run_log,
            rid: None,
            repo_name: None,
+
            request: None,
            commit: None,
            storage: None,
            timeout: None,
@@ -52,6 +54,11 @@ impl Run {
        })
    }

+
    /// Set the message that triggered this run.
+
    pub fn set_request(&mut self, req: Request) {
+
        self.request = Some(req);
+
    }
+

    /// Set the git repository to use for this run.
    pub fn set_repository(&mut self, rid: RepoId, repo_name: &str) {
        self.rid = Some(rid);