diff --git a/ofborg/src/commitstatus.rs b/ofborg/src/commitstatus.rs index 8ee6dd64..f4fb3fab 100644 --- a/ofborg/src/commitstatus.rs +++ b/ofborg/src/commitstatus.rs @@ -1,7 +1,10 @@ +use crate::ghrepo; + +use std::rc::Rc; use tracing::warn; pub struct CommitStatus<'a> { - api: hubcaps::statuses::Statuses<'a>, + repo_client: Rc, sha: String, context: String, description: String, @@ -10,14 +13,14 @@ pub struct CommitStatus<'a> { impl<'a> CommitStatus<'a> { pub fn new( - api: hubcaps::statuses::Statuses<'a>, + repo_client: Rc, sha: String, context: String, description: String, url: Option, ) -> CommitStatus<'a> { let mut stat = CommitStatus { - api, + repo_client, sha, context, description, @@ -57,8 +60,8 @@ impl<'a> CommitStatus<'a> { self.description.clone() }; - self.api - .create( + self.repo_client + .create_status( self.sha.as_ref(), &hubcaps::statuses::StatusOptions::builder(state) .context(self.context.clone()) diff --git a/ofborg/src/ghrepo.rs b/ofborg/src/ghrepo.rs index ab40f43a..03df1bc8 100644 --- a/ofborg/src/ghrepo.rs +++ b/ofborg/src/ghrepo.rs @@ -1,4 +1,3 @@ -use crate::commitstatus; use crate::message; use hubcaps::checks::{CheckRun, CheckRunOptions}; @@ -22,13 +21,6 @@ pub trait Client { ) -> hubcaps::Result; fn create_status(&self, sha: &str, status: &StatusOptions) -> hubcaps::Result; fn create_checkrun(&self, check: &CheckRunOptions) -> hubcaps::Result; - fn create_commitstatus( - &self, - pr: &message::Pr, - context: String, - description: String, - gist_url: Option, - ) -> commitstatus::CommitStatus; } pub struct Hubcaps<'a> { @@ -76,20 +68,4 @@ impl Client for Hubcaps<'_> { fn create_checkrun(&self, check: &CheckRunOptions) -> hubcaps::Result { self.repo.checkruns().create(&check) } - - fn create_commitstatus( - &self, - pr: &message::Pr, - context: String, - description: String, - gist_url: Option, - ) -> commitstatus::CommitStatus { - commitstatus::CommitStatus::new( - self.repo.statuses(), - pr.head_sha.clone(), - context, - description, - gist_url, - ) - } } diff --git a/ofborg/src/tasks/eval/nixpkgs.rs b/ofborg/src/tasks/eval/nixpkgs.rs index 7bff8eca..6d5eb04e 100644 --- a/ofborg/src/tasks/eval/nixpkgs.rs +++ b/ofborg/src/tasks/eval/nixpkgs.rs @@ -278,8 +278,9 @@ impl<'a> NixpkgsStrategy<'a> { "pull request has {} changed paths, skipping review requests", changed_paths.len() ); - let status = self.repo_client.create_commitstatus( - &self.job.pr, + let status = CommitStatus::new( + self.repo_client.clone(), + self.job.pr.head_sha.clone(), String::from("grahamcofborg-eval-check-maintainers"), String::from("large change, skipping automatic review requests"), gist_url, @@ -288,8 +289,9 @@ impl<'a> NixpkgsStrategy<'a> { return Ok(()); } - let status = self.repo_client.create_commitstatus( - &self.job.pr, + let status = CommitStatus::new( + self.repo_client.clone(), + self.job.pr.head_sha.clone(), String::from("grahamcofborg-eval-check-maintainers"), String::from("matching changed paths to changed attrs..."), gist_url, @@ -318,8 +320,9 @@ impl<'a> NixpkgsStrategy<'a> { fn check_meta_queue_builds(&self, dir: &Path) -> StepResult> { if let Some(ref possibly_touched_packages) = self.touched_packages { - let mut status = self.repo_client.create_commitstatus( - &self.job.pr, + let mut status = CommitStatus::new( + self.repo_client.clone(), + self.job.pr.head_sha.clone(), String::from("grahamcofborg-eval-check-meta"), String::from("config.nix: checkMeta = true"), None, diff --git a/ofborg/src/tasks/evaluate.rs b/ofborg/src/tasks/evaluate.rs index 0e982bf0..af86229b 100644 --- a/ofborg/src/tasks/evaluate.rs +++ b/ofborg/src/tasks/evaluate.rs @@ -1,7 +1,7 @@ /// This is what evaluates every pull-request use crate::acl::ACL; use crate::checkout; -use crate::commitstatus::CommitStatusError; +use crate::commitstatus::{CommitStatus, CommitStatusError}; use crate::config::GithubAppVendingMachine; use crate::files::file_to_str; use crate::ghgist; @@ -290,8 +290,9 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> { Box::new(eval::GenericStrategy::new()) }; - let mut overall_status = self.repo_client.create_commitstatus( - &job.pr, + let mut overall_status = CommitStatus::new( + self.repo_client.clone(), + job.pr.head_sha.clone(), "grahamcofborg-eval".to_string(), "Starting".to_string(), None, @@ -373,8 +374,9 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> { .evaluation_checks() .into_iter() .map(|check| { - let mut status = self.repo_client.create_commitstatus( - &job.pr, + let mut status = CommitStatus::new( + self.repo_client.clone(), + job.pr.head_sha.clone(), check.name(), check.cli_cmd(), None,