summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ci_ctl.rs16
-rw-r--r--src/dbctx.rs12
2 files changed, 27 insertions, 1 deletions
diff --git a/src/ci_ctl.rs b/src/ci_ctl.rs
index 3f48907..687aa46 100644
--- a/src/ci_ctl.rs
+++ b/src/ci_ctl.rs
@@ -47,6 +47,9 @@ enum JobAction {
List,
Rerun {
which: u32
+ },
+ RerunCommit {
+ commit: String
}
}
@@ -93,6 +96,17 @@ fn main() {
.expect("works");
eprintln!("[+] job {} set to pending", which);
}
+ JobAction::RerunCommit { commit } => {
+ let db = DbCtx::new(&config_path, &db_path);
+ let job_id = db.job_for_commit(&commit).unwrap();
+ if let Some(job_id) = job_id {
+ db.conn.lock().unwrap().execute("update jobs set state=0 where id=?1", [job_id])
+ .expect("works");
+ eprintln!("[+] job {} (commit {}) set to pending", job_id, commit);
+ } else {
+ eprintln!("[-] no job for commit {}", commit);
+ }
+ }
}
},
Command::Add { what } => {
@@ -131,7 +145,7 @@ fn main() {
};
println!("[+] new repo created: '{}' id {}", &name, repo_id);
if let Some((remote, remote_kind, config_path)) = remote_config {
- let full_config_file_path = format!("{}/{}", &db.config_path, config_path);
+ let full_config_file_path = format!("{}/{}", &db.config_path.display(), config_path);
let config = match remote_kind.as_ref() {
"github" => {
assert!(NotifierConfig::github_from_file(&full_config_file_path).is_ok());
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()