aboutsummaryrefslogtreecommitdiff
path: root/mod/ci-common.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-05-26 13:46:55 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-05-28 13:58:46 +0300
commita7ae434c48c14bfde46a871455a3aa2ac0b81376 (patch)
tree2d4f66a2e153842e166becfcbb2a820036faffcb /mod/ci-common.cxx
parent5e631e5f63fdc8528d5d178d6a66dfb32a2c0f8b (diff)
Add CI cancel handler
Diffstat (limited to 'mod/ci-common.cxx')
-rw-r--r--mod/ci-common.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/mod/ci-common.cxx b/mod/ci-common.cxx
index 7c41a7b..c0ef89f 100644
--- a/mod/ci-common.cxx
+++ b/mod/ci-common.cxx
@@ -720,4 +720,40 @@ namespace brep
return r;
}
+
+ bool ci_start::
+ cancel (const basic_mark&,
+ const basic_mark&,
+ const basic_mark* trace,
+ const string& reason,
+ odb::core::database& db,
+ const string& tid) const
+ {
+ using namespace odb::core;
+
+ assert (!transaction::has_current ());
+
+ transaction tr (db.begin ());
+
+ shared_ptr<build_tenant> t (db.find<build_tenant> (tid));
+
+ if (t == nullptr)
+ return false;
+
+ if (!t->archived)
+ {
+ t->archived = true;
+ db.update (t);
+ }
+
+ tr.commit ();
+
+ if (trace != nullptr)
+ *trace << "CI request " << tid << " is canceled: "
+ << (reason.size () < 50
+ ? reason
+ : string (reason, 0, 50) + "...");
+
+ return true;
+ }
}