From 22059500a799d788c09171e31b668ab8259ec057 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 17 Nov 2018 23:41:25 +0300 Subject: Add support for builds manifest value --- mod/mod-package-version-details.cxx | 66 ++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 37 deletions(-) (limited to 'mod/mod-package-version-details.cxx') diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index bafe8f7..9566c8f 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -10,8 +10,6 @@ #include #include -#include // alpha(), ucase(), lcase() - #include #include #include @@ -390,24 +388,48 @@ handle (request& rq, response& rs) if (builds) { + using bbot::build_config; + s << H3 << "Builds" << ~H3 << DIV(ID="builds"); + auto exclude = [&pkg] (const build_config& cfg, string* reason = nullptr) + { + return brep::exclude (pkg->builds, pkg->build_constraints, cfg, reason); + }; + timestamp now (system_clock::now ()); transaction t (build_db_->begin ()); - // Print built package configurations. + // Print built package configurations, except those that are hidden or + // excluded by the package. // + cstrings conf_names; + + for (const auto& c: *build_conf_map_) + { + if (belongs (*c.second, "all")) + conf_names.push_back (c.first); + } + using query = query; for (auto& b: build_db_->query ( (query::id.package == pkg->id && - query::id.configuration.in_range (build_conf_names_->begin (), - build_conf_names_->end ())) + + query::id.configuration.in_range (conf_names.begin (), + conf_names.end ())) + "ORDER BY" + query::timestamp + "DESC")) { + auto i (build_conf_map_->find (b.configuration.c_str ())); + assert (i != build_conf_map_->end ()); + + const build_config& cfg (*i->second); + + if (exclude (cfg)) + continue; + string ts (butl::to_string (b.timestamp, "%Y-%m-%d %H:%M:%S %Z", true, @@ -430,42 +452,12 @@ handle (request& rq, response& rs) << ~TABLE; } - // Print configurations that are excluded by the package. + // Print the package build exclusions that belong to the 'default' class. // - auto excluded = [&pkg] (const bbot::build_config& c, string& reason) - { - for (const auto& bc: pkg->build_constraints) - { - if (match (bc.config, bc.target, c)) - { - if (!bc.exclusion) - return false; - - // Save the first sentence of the exclusion comment, lower-case the - // first letter if the beginning looks like a word (the second - // character is the lower-case letter or space). - // - reason = bc.comment.substr (0, bc.comment.find ('.')); - - char c; - size_t n (reason.size ()); - if (n > 0 && alpha (c = reason[0]) && c == ucase (c) && - (n == 1 || - (alpha (c = reason[1]) && c == lcase (c)) || - c == ' ')) - reason[0] = lcase (reason[0]); - - return true; - } - } - - return false; - }; - for (const auto& c: *build_conf_) { string reason; - if (excluded (c, reason)) + if (belongs (c, "default") && exclude (c, &reason)) { s << TABLE(CLASS="proplist build") << TBODY -- cgit v1.1