fix: pass in request to run log

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-05-14 17:53:34 +03:00
parent 7e4a761035
commit 153c4fdcc5
2 changed files with 12 additions and 3 deletions
+4 -2
View File
@@ -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());
+8 -1
View File
@@ -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);