diff --git a/src/engine.rs b/src/engine.rs index f6fba6b..651f215 100644 --- a/src/engine.rs +++ b/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()); diff --git a/src/run.rs b/src/run.rs index 035a45d..655f8cb 100644 --- a/src/run.rs +++ b/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, + request: Option, repo_name: Option, commit: Option, storage: Option, @@ -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);