diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-10-23 18:45:47 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-10-24 09:51:31 +0200 |
commit | 85065024eb4ca2ec1dac4dc7cb1fc8ff8fb238c8 (patch) | |
tree | 8b428bef700e2c5801d3ab96313b6f4d6b9f3b38 /mod/ci-common.cxx | |
parent | 295cdbd98a261559e34f8453e149e6be5bafcc5a (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; + } } |