summaryrefslogtreecommitdiff
path: root/src/ci_ctl.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-07-04 19:32:38 -0700
committeriximeow <me@iximeow.net>2023-07-04 19:32:38 -0700
commit543150f1666690351d4698421cc6ceb115c1e251 (patch)
tree97be63ef2d0c28d5f9461279ddf6a842a44c25eb /src/ci_ctl.rs
parentd3b9a921d25412ffbafb9b9b500620aa500d55ac (diff)
[ci_ctl] command to artificially create new jobs
Diffstat (limited to 'src/ci_ctl.rs')
-rw-r--r--src/ci_ctl.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ci_ctl.rs b/src/ci_ctl.rs
index 6d8b004..f0ffa62 100644
--- a/src/ci_ctl.rs
+++ b/src/ci_ctl.rs
@@ -51,6 +51,11 @@ enum JobAction {
},
RerunCommit {
commit: String
+ },
+ Create {
+ repo: String,
+ commit: String,
+ pusher_email: String,
}
}
@@ -111,6 +116,27 @@ fn main() {
eprintln!("[-] no job for commit {}", commit);
}
}
+ JobAction::Create { repo, commit, pusher_email } => {
+ let db = DbCtx::new(&config_path, &db_path);
+ let parts = repo.split(":").collect::<Vec<&str>>();
+ let (remote_kind, repo_path) = (parts[0], parts[1]);
+ let remote = match db.remote_by_path_and_api(&remote_kind, &repo_path).expect("can query") {
+ Some(remote) => remote,
+ None => {
+ eprintln!("[-] no remote registered as {}:{}", remote_kind, repo_path);
+ return;
+ }
+ };
+
+ let repo_default_run_pref: Option<String> = db.conn.lock().unwrap()
+ .query_row("select default_run_preference from repos where id=?1;", [remote.repo_id], |row| {
+ Ok((row.get(0)).unwrap())
+ })
+ .expect("can query");
+
+ let job_id = db.new_job(remote.id, &commit, Some(&pusher_email), repo_default_run_pref).expect("can create");
+ let _ = db.new_run(job_id, None).unwrap();
+ }
}
},
Command::Add { what } => {