diff options
author | iximeow <git@iximeow.net> | 2022-12-27 23:45:18 +0000 |
---|---|---|
committer | iximeow <git@iximeow.net> | 2022-12-27 23:46:27 +0000 |
commit | 3411ef67fb829c419f853293664d97c6a6d4b96b (patch) | |
tree | 4101f4acac71fdd98074407c964d94635e3f2eb9 /src/dbctx.rs | |
parent | a4dcaedc05c667a293d98848fbecd76c8708a298 (diff) |
cictl rerun by-commit not just job id
what happens if there are multiple jobs for the same commit? nothing good, really!
Diffstat (limited to 'src/dbctx.rs')
-rw-r--r-- | src/dbctx.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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<Option<u64>, 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<Option<(u64, Option<String>, TokenValidity)>, String> { self.conn.lock() .unwrap() |