diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-10-23 18:45:47 +0200 |
---|---|---|
committer | Francois Kritzinger <francois@codesynthesis.com> | 2024-12-10 16:34:15 +0200 |
commit | 33fce80ada305a5c3489e5716d515106b0fe73b2 (patch) | |
tree | 0f42fc0217d11bf1e23ac12b99e7b9819e125f07 /mod/ci-common.cxx | |
parent | e5e3c528e64c09e5493e821f700c959560432678 (diff) |
Add ci_start::rebuild() function
Diffstat (limited to 'mod/ci-common.cxx')
-rw-r--r-- | mod/ci-common.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
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 <libbutl/process-io.hxx> // operator<<(ostream, process_args) #include <libbutl/manifest-serializer.hxx> +#include <libbrep/build.hxx> +#include <libbrep/build-odb.hxx> #include <libbrep/build-package.hxx> #include <libbrep/build-package-odb.hxx> @@ -815,4 +817,43 @@ namespace brep return true; } + + optional<build_state> 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<package_build> (query<package_build>::build::id == id, + pb) || + pb.archived) + { + return nullopt; + } + + const shared_ptr<build>& 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; + } } |