From 33fce80ada305a5c3489e5716d515106b0fe73b2 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 23 Oct 2024 18:45:47 +0200 Subject: Add ci_start::rebuild() function --- mod/ci-common.cxx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'mod/ci-common.cxx') diff --git a/mod/ci-common.cxx b/mod/ci-common.cxx index 5191d46..11d55af 100644 --- a/mod/ci-common.cxx +++ b/mod/ci-common.cxx @@ -14,6 +14,8 @@ #include // operator<<(ostream, process_args) #include +#include +#include #include #include @@ -815,4 +817,43 @@ namespace brep return true; } + + optional ci_start:: + rebuild (odb::core::database& db, const build_id& id) const + { + using namespace odb::core; + + // NOTE: don't forget to update build_force::handle() if changing anything + // here. + // + transaction t (db.begin ()); + + package_build pb; + if (!db.query_one (query::build::id == id, + pb) || + pb.archived) + { + return nullopt; + } + + const shared_ptr& b (pb.build); + build_state s (b->state); + + if (s != build_state::queued) + { + force_state force (s == build_state::built + ? force_state::forced + : force_state::forcing); + + if (b->force != force) + { + b->force = force; + db.update (b); + } + } + + t.commit (); + + return s; + } } -- cgit v1.1