aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-06-12 13:57:31 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-06-12 14:00:28 +0300
commit20a456e33222ed31008db3c328f1e10c212acf00 (patch)
tree49656edebb9e6ad6bb139d46d52a8c45c6e2af65
parenta259cbd13dcf9a25fdd758fc18f7611e1ac404f6 (diff)
Make project url and email optional in package manifest
-rw-r--r--libbrep/package.cxx4
-rw-r--r--libbrep/package.hxx12
-rw-r--r--libbrep/package.xml10
-rw-r--r--mod/mod-build-result.cxx23
-rw-r--r--mod/mod-package-details.cxx12
-rw-r--r--mod/mod-package-version-details.cxx20
-rw-r--r--tests/load/1/math/libfoo-1.0.tar.gzbin258 -> 219 bytes
-rw-r--r--tests/load/1/math/packages.manifest4
-rw-r--r--tests/load/1/stable/libfoo-1.0.tar.gzbin258 -> 219 bytes
-rw-r--r--tests/load/1/stable/packages.manifest4
-rw-r--r--tests/load/1/stable/signature.manifest20
-rw-r--r--tests/load/driver.cxx46
12 files changed, 82 insertions, 73 deletions
diff --git a/libbrep/package.cxx b/libbrep/package.cxx
index 7d94422..3e457b2 100644
--- a/libbrep/package.cxx
+++ b/libbrep/package.cxx
@@ -55,11 +55,11 @@ namespace brep
strings tg,
optional<string> ds,
string ch,
- url_type ur,
+ optional<url_type> ur,
optional<url_type> du,
optional<url_type> su,
optional<url_type> pu,
- email_type em,
+ optional<email_type> em,
optional<email_type> pe,
optional<email_type> be,
dependencies_type dp,
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index b86350e..d403784 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -19,9 +19,9 @@
// Used by the data migration entries.
//
-#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 6
+#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 7
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 6, closed)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 7, open)
namespace brep
{
@@ -306,11 +306,11 @@ namespace brep
strings tags,
optional<string> description,
string changes,
- url_type,
+ optional<url_type>,
optional<url_type> doc_url,
optional<url_type> src_url,
optional<url_type> package_url,
- email_type,
+ optional<email_type>,
optional<email_type> package_email,
optional<email_type> build_email,
dependencies_type,
@@ -342,11 +342,11 @@ namespace brep
strings tags;
optional<string> description;
string changes;
- url_type url;
+ optional<url_type> url;
optional<url_type> doc_url;
optional<url_type> src_url;
optional<url_type> package_url;
- email_type email;
+ optional<email_type> email;
optional<email_type> package_email;
optional<email_type> build_email;
dependencies_type dependencies;
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 9b83bb2..08ecc61 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,5 +1,5 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
- <model version="6">
+ <model version="7">
<table name="repository" kind="object">
<column name="name" type="TEXT" null="false"/>
<column name="location" type="TEXT" null="false"/>
@@ -82,16 +82,16 @@
<column name="summary" type="TEXT" null="false"/>
<column name="description" type="TEXT" null="true"/>
<column name="changes" type="TEXT" null="false"/>
- <column name="url" type="TEXT" null="false"/>
- <column name="url_comment" type="TEXT" null="false"/>
+ <column name="url" type="TEXT" null="true"/>
+ <column name="url_comment" type="TEXT" null="true"/>
<column name="doc_url" type="TEXT" null="true"/>
<column name="doc_url_comment" type="TEXT" null="true"/>
<column name="src_url" type="TEXT" null="true"/>
<column name="src_url_comment" type="TEXT" null="true"/>
<column name="package_url" type="TEXT" null="true"/>
<column name="package_url_comment" type="TEXT" null="true"/>
- <column name="email" type="TEXT" null="false"/>
- <column name="email_comment" type="TEXT" null="false"/>
+ <column name="email" type="TEXT" null="true"/>
+ <column name="email_comment" type="TEXT" null="true"/>
<column name="package_email" type="TEXT" null="true"/>
<column name="package_email_comment" type="TEXT" null="true"/>
<column name="build_email" type="TEXT" null="true"/>
diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx
index 1253d14..7891fe1 100644
--- a/mod/mod-build-result.cxx
+++ b/mod/mod-build-result.cxx
@@ -379,6 +379,18 @@ handle (request& rq, response&)
if (!notify || (build_email && build_email->empty ()))
return true;
+ // If the package build address is not specified, then it is assumed to be
+ // the same as the package email address, if specified, otherwise as the
+ // project email address, if specified, otherwise the notification email is
+ // not sent.
+ //
+ const optional<email>& to (build_email ? build_email
+ : p->package_email
+ ? p->package_email
+ : p->email);
+ if (!to)
+ return true;
+
assert (b != nullptr);
// Send email to the package owner.
@@ -391,15 +403,6 @@ handle (request& rq, response&)
b->package_version.string () + '/' + b->configuration + '/' +
b->toolchain_name + '-' + b->toolchain_version.string ());
- // If the package build address is not specified, then it is assumed to be
- // the same as the package email address, if specified, otherwise as the
- // project email address.
- //
- const string& to (build_email ? *build_email
- : p->package_email
- ? *p->package_email
- : p->email);
-
// Redirect the diagnostics to webserver error log.
//
// Note: if using this somewhere else, then need to factor out all this
@@ -409,7 +412,7 @@ handle (request& rq, response&)
2,
options_->email (),
subj,
- {to});
+ {*to});
if (b->results.empty ())
sm.out << "No operation results available." << endl;
diff --git a/mod/mod-package-details.cxx b/mod/mod-package-details.cxx
index c56d91a..a348d95 100644
--- a/mod/mod-package-details.cxx
+++ b/mod/mod-package-details.cxx
@@ -186,8 +186,10 @@ handle (request& rq, response& rs)
s << TABLE(CLASS="proplist", ID="package")
<< TBODY
- << TR_LICENSE (licenses)
- << TR_URL (pkg->url);
+ << TR_LICENSE (licenses);
+
+ if (pkg->url)
+ s << TR_URL (*pkg->url);
if (pkg->doc_url)
s << TR_URL (*pkg->doc_url, "doc-url");
@@ -195,8 +197,10 @@ handle (request& rq, response& rs)
if (pkg->src_url)
s << TR_URL (*pkg->src_url, "src-url");
- s << TR_EMAIL (pkg->email)
- << TR_TAGS (pkg->tags, root)
+ if (pkg->email)
+ s << TR_EMAIL (*pkg->email);
+
+ s << TR_TAGS (pkg->tags, root)
<< ~TBODY
<< ~TABLE;
}
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index 2134cc6..cef9357 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -205,8 +205,12 @@ handle (request& rq, response& rs)
<< ~TABLE
<< TABLE(CLASS="proplist", ID="package")
- << TBODY
- << TR_URL (pkg->url);
+ << TBODY;
+
+ const auto& u (pkg->url);
+
+ if (u)
+ s << TR_URL (*u);
if (pkg->doc_url)
s << TR_URL (*pkg->doc_url, "doc-url");
@@ -215,18 +219,20 @@ handle (request& rq, response& rs)
s << TR_URL (*pkg->src_url, "src-url");
const auto& pu (pkg->package_url);
- if (pu && *pu != pkg->url)
+ if (pu && pu != u)
s << TR_URL (*pu, "package-url");
- const email& em (pkg->email);
- s << TR_EMAIL (em);
+ const auto& em (pkg->email);
+
+ if (em)
+ s << TR_EMAIL (*em);
const auto& pe (pkg->package_email);
- if (pe && *pe != em)
+ if (pe && pe != em)
s << TR_EMAIL (*pe, "package-email");
const auto& be (pkg->build_email);
- if (be && ((pe && *be != *pe) || (!pe && *be != em)))
+ if (be && ((pe && be != pe) || (!pe && be != em)))
s << TR_EMAIL (*be, "build-email");
s << TR_TAGS (pkg->tags, root)
diff --git a/tests/load/1/math/libfoo-1.0.tar.gz b/tests/load/1/math/libfoo-1.0.tar.gz
index 5063f1b..2014fc1 100644
--- a/tests/load/1/math/libfoo-1.0.tar.gz
+++ b/tests/load/1/math/libfoo-1.0.tar.gz
Binary files differ
diff --git a/tests/load/1/math/packages.manifest b/tests/load/1/math/packages.manifest
index 3c6e325..50db2dc 100644
--- a/tests/load/1/math/packages.manifest
+++ b/tests/load/1/math/packages.manifest
@@ -21,10 +21,8 @@ name: libfoo
version: 1.0
summary: The Foo Library
license: MIT
-url: http://www.example.com/foo/
-email: foo-users@example.com
location: libfoo-1.0.tar.gz
-sha256sum: d8ad319b55fdd19ff24cb0fcf9d61101289569f80b8688884389587cfafa1f1e
+sha256sum: 0df6d45a3514c6101609bdcfefe7659b5754e505c6cf6b4107141d8217bb981d
:
name: libfoo
version: 1.2.4+1
diff --git a/tests/load/1/stable/libfoo-1.0.tar.gz b/tests/load/1/stable/libfoo-1.0.tar.gz
index 5063f1b..2014fc1 100644
--- a/tests/load/1/stable/libfoo-1.0.tar.gz
+++ b/tests/load/1/stable/libfoo-1.0.tar.gz
Binary files differ
diff --git a/tests/load/1/stable/packages.manifest b/tests/load/1/stable/packages.manifest
index d61b6e2..af3bc32 100644
--- a/tests/load/1/stable/packages.manifest
+++ b/tests/load/1/stable/packages.manifest
@@ -5,10 +5,8 @@ name: libfoo
version: 1.0
summary: The Foo Library
license: MIT
-url: http://www.example.com/foo/
-email: foo-users@example.com
location: libfoo-1.0.tar.gz
-sha256sum: d8ad319b55fdd19ff24cb0fcf9d61101289569f80b8688884389587cfafa1f1e
+sha256sum: 0df6d45a3514c6101609bdcfefe7659b5754e505c6cf6b4107141d8217bb981d
:
name: libfoo
version: 1.2.2-alpha.1
diff --git a/tests/load/1/stable/signature.manifest b/tests/load/1/stable/signature.manifest
index ccd7b66..b0fd9a8 100644
--- a/tests/load/1/stable/signature.manifest
+++ b/tests/load/1/stable/signature.manifest
@@ -1,13 +1,13 @@
: 1
-sha256sum: 5ecbb89c8e36b9743fe08a3e53ceefe410ac13f9e1549300a58bcf83aa17e30c
+sha256sum: 6eaeabb5824a3174435c9dbfdd8eba8a6b3e29133dcd2963f69745a4bb704ed2
signature: \
-X16KuI/I780t/KA34PgPgxWMu6mELo08WQVm0Z8f00KvPR1xKow2NMNatDZmtA4oAgAnkUA0tU0Z
-G1qdAxwRwCcAYGwKPDT/3hX2oExbyBpU22pTJyQ9nG67CTdv8FXaCrcEP2ZWX43LfQBqagYwNZYH
-ZGKloFNwyT5dAc1z2eMBOqQ8cgT8glGOnk9p39Hb02HGhbeUiO/gLwVr7u76sibXZ9TjuXdiE4SE
-uBByHhoQOPPvoBtBilDy5S0XqQAig3Rg1qDpURodXz7fgebbQ2HtjS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CGxyCuSm6He91Y9S9OoIE=
\
diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx
index 3538863..c86258b 100644
--- a/tests/load/driver.cxx
+++ b/tests/load/driver.cxx
@@ -43,12 +43,11 @@ check_location (shared_ptr<package>& p)
static bool
check_external (const package& p)
{
- return p.summary.empty () && p.tags.empty () && !p.description &&
- p.url.empty () && !p.package_url && p.email.empty () &&
- !p.package_email && !p.internal () && p.other_repositories.size () > 0 &&
- p.priority == priority () && p.changes.empty () &&
- p.license_alternatives.empty () && p.dependencies.empty () &&
- p.requirements.empty () && !p.sha256sum;
+ return p.summary.empty () && p.tags.empty () && !p.description && !p.url &&
+ !p.package_url && !p.email && !p.package_email && !p.internal () &&
+ p.other_repositories.size () > 0 && p.priority == priority () &&
+ p.changes.empty () && p.license_alternatives.empty () &&
+ p.dependencies.empty () && p.requirements.empty () && !p.sha256sum;
}
namespace bpkg
@@ -200,9 +199,9 @@ main (int argc, char* argv[])
assert (fpv1->summary == "The Foo Library");
assert (fpv1->tags.empty ());
assert (!fpv1->description);
- assert (fpv1->url == "http://www.example.com/foo/");
+ assert (!fpv1->url);
assert (!fpv1->package_url);
- assert (fpv1->email == "foo-users@example.com");
+ assert (!fpv1->email);
assert (!fpv1->package_email);
assert (fpv1->internal_repository.load () == sr);
@@ -223,7 +222,7 @@ main (int argc, char* argv[])
assert (check_location (fpv1));
assert (fpv1->sha256sum && *fpv1->sha256sum ==
- "d8ad319b55fdd19ff24cb0fcf9d61101289569f80b8688884389587cfafa1f1e");
+ "0df6d45a3514c6101609bdcfefe7659b5754e505c6cf6b4107141d8217bb981d");
// libfoo-1.2.2
//
@@ -234,9 +233,9 @@ main (int argc, char* argv[])
assert (fpv2->summary == "The Foo library");
assert (fpv2->tags == strings ({"c++", "foo"}));
assert (!fpv2->description);
- assert (fpv2->url == "http://www.example.com/foo/");
+ assert (fpv2->url && *fpv2->url == "http://www.example.com/foo/");
assert (!fpv2->package_url);
- assert (fpv2->email == "foo-users@example.com");
+ assert (fpv2->email && *fpv2->email == "foo-users@example.com");
assert (!fpv2->package_email);
assert (fpv2->internal_repository.load () == sr);
@@ -287,9 +286,9 @@ main (int argc, char* argv[])
assert (fpv2a->summary == "The Foo library");
assert (fpv2a->tags == strings ({"c++", "foo"}));
assert (!fpv2a->description);
- assert (fpv2a->url == "http://www.example.com/foo/");
+ assert (fpv2a->url && *fpv2a->url == "http://www.example.com/foo/");
assert (!fpv2a->package_url);
- assert (fpv2a->email == "foo-users@example.com");
+ assert (fpv2a->email && *fpv2a->email == "foo-users@example.com");
assert (!fpv2a->package_email);
assert (fpv2a->internal_repository.load () == sr);
@@ -357,9 +356,9 @@ main (int argc, char* argv[])
assert (fpv3->summary == "The Foo library");
assert (fpv3->tags == strings ({"c++", "foo"}));
assert (!fpv3->description);
- assert (fpv3->url == "http://www.example.com/foo/");
+ assert (fpv3->url && *fpv3->url == "http://www.example.com/foo/");
assert (!fpv3->package_url);
- assert (fpv3->email == "foo-users@example.com");
+ assert (fpv3->email && *fpv3->email == "foo-users@example.com");
assert (!fpv3->package_email);
assert (fpv3->internal_repository.load () == sr);
@@ -395,9 +394,9 @@ main (int argc, char* argv[])
assert (fpv4->summary == "The Foo Library");
assert (fpv4->tags == strings ({"c++", "foo"}));
assert (*fpv4->description == "Very good foo library.");
- assert (fpv4->url == "http://www.example.com/foo/");
+ assert (fpv4->url && *fpv4->url == "http://www.example.com/foo/");
assert (!fpv4->package_url);
- assert (fpv4->email == "foo-users@example.com");
+ assert (fpv4->email && *fpv4->email == "foo-users@example.com");
assert (!fpv4->package_email);
assert (fpv4->internal_repository.load () == sr);
@@ -464,9 +463,10 @@ main (int argc, char* argv[])
assert (xpv->tags == strings ({"c++", "xml", "parser", "serializer",
"pull", "streaming", "modern"}));
assert (!xpv->description);
- assert (xpv->url == "http://www.codesynthesis.com/projects/libstudxml/");
+ assert (xpv->url &&
+ *xpv->url == "http://www.codesynthesis.com/projects/libstudxml/");
assert (!xpv->package_url);
- assert (xpv->email ==
+ assert (xpv->email && *xpv->email ==
email ("studxml-users@codesynthesis.com",
"Public mailing list, posts by non-members "
"are allowed but moderated."));
@@ -519,7 +519,7 @@ main (int argc, char* argv[])
"MATLAB.\n\nUseful for conversion of research code into "
"production environments.");
- assert (fpv5->url == "http://www.example.com/foo/");
+ assert (fpv5->url && *fpv5->url == "http://www.example.com/foo/");
assert (fpv5->doc_url && *fpv5->doc_url ==
"http://www.example.org/projects/libfoo/man.xhtml" &&
@@ -531,7 +531,7 @@ main (int argc, char* argv[])
assert (fpv5->package_url &&
*fpv5->package_url == "http://www.example.com/foo/pack");
- assert (fpv5->email == "foo-users@example.com");
+ assert (fpv5->email && *fpv5->email == "foo-users@example.com");
assert (fpv5->package_email &&
*fpv5->package_email == "pack@example.com");
@@ -634,9 +634,9 @@ main (int argc, char* argv[])
assert (epv->tags == strings ({"c++", "exponent"}));
assert (epv->description && *epv->description ==
"The exponent math function.");
- assert (epv->url == "http://www.exp.com");
+ assert (epv->url && *epv->url == "http://www.exp.com");
assert (!epv->package_url);
- assert (epv->email == email ("users@exp.com"));
+ assert (epv->email && *epv->email == email ("users@exp.com"));
assert (!epv->package_email);
assert (epv->build_email && *epv->build_email == "builds@exp.com");