From 3411ef67fb829c419f853293664d97c6a6d4b96b Mon Sep 17 00:00:00 2001 From: iximeow Date: Tue, 27 Dec 2022 23:45:18 +0000 Subject: cictl rerun by-commit not just job id what happens if there are multiple jobs for the same commit? nothing good, really! --- src/dbctx.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/dbctx.rs') diff --git a/src/dbctx.rs b/src/dbctx.rs index 937b887..1bb8bc8 100644 --- a/src/dbctx.rs +++ b/src/dbctx.rs @@ -150,6 +150,18 @@ impl DbCtx { ArtifactDescriptor::new(job_id, artifact_id).await } + pub fn job_for_commit(&self, sha: &str) -> Result, String> { + self.conn.lock() + .unwrap() + .query_row( + "select id from commits where sha=?1", + [sha], + |row| { row.get(0) } + ) + .optional() + .map_err(|e| e.to_string()) + } + pub fn job_for_token(&self, token: &str) -> Result, TokenValidity)>, String> { self.conn.lock() .unwrap() -- cgit v1.1