aboutsummaryrefslogtreecommitdiff
path: root/bpkg
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-12 12:39:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-18 13:50:39 +0200
commit0103e8a96182ad12b3b98629ffe295a706ddcb66 (patch)
tree92beb9e92bc51b53c9d2aa6fc5a7163479825081 /bpkg
parent15077a1f309d615dcd905b0aec009cd079475327 (diff)
Add url, email, summary, description members to the repository_manifest class
Diffstat (limited to 'bpkg')
-rw-r--r--bpkg/manifest7
-rw-r--r--bpkg/manifest.cxx94
2 files changed, 100 insertions, 1 deletions
diff --git a/bpkg/manifest b/bpkg/manifest
index cc45bb4..106b6ca 100644
--- a/bpkg/manifest
+++ b/bpkg/manifest
@@ -469,6 +469,13 @@ namespace bpkg
repository_location location;
butl::optional<repository_role> role;
+ // The following values may only be present for the base repository.
+ //
+ butl::optional<std::string> url;
+ butl::optional<std::string> email;
+ butl::optional<std::string> summary;
+ butl::optional<std::string> description;
+
public:
repository_manifest (manifest_parser&);
repository_manifest (manifest_parser&, manifest_name_value start);
diff --git a/bpkg/manifest.cxx b/bpkg/manifest.cxx
index d421e7e..3857c28 100644
--- a/bpkg/manifest.cxx
+++ b/bpkg/manifest.cxx
@@ -1245,6 +1245,46 @@ namespace bpkg
role = static_cast<repository_role> (i - b);
}
+ else if (n == "url")
+ {
+ if (url)
+ bad_name ("url redefinition");
+
+ if (v.empty ())
+ bad_value ("empty url");
+
+ url = move (v);
+ }
+ else if (n == "email")
+ {
+ if (email)
+ bad_name ("email redefinition");
+
+ if (v.empty ())
+ bad_value ("empty email");
+
+ email = move (v);
+ }
+ else if (n == "summary")
+ {
+ if (summary)
+ bad_name ("summary redefinition");
+
+ if (v.empty ())
+ bad_value ("empty summary");
+
+ summary = move (v);
+ }
+ else if (n == "description")
+ {
+ if (description)
+ bad_name ("description redefinition");
+
+ if (v.empty ())
+ bad_value ("empty description");
+
+ description = move (v);
+ }
else
bad_name ("unknown name '" + n + "' in repository manifest");
}
@@ -1256,11 +1296,29 @@ namespace bpkg
//
if (role && location.empty () != (*role == repository_role::base))
bad_value ("invalid role");
+
+ if (effective_role () != repository_role::base)
+ {
+ if (url)
+ bad_value ("url not allowed");
+
+ if (email)
+ bad_value ("email not allowed");
+
+ if (summary)
+ bad_value ("summary not allowed");
+
+ if (description)
+ bad_value ("description not allowed");
+ }
}
void repository_manifest::
serialize (serializer& s) const
{
+ auto bad_value ([&s](const string& d) {
+ throw serialization (s.name (), d);});
+
s.next ("", "1"); // Start of manifest.
if (!location.empty ())
@@ -1269,13 +1327,47 @@ namespace bpkg
if (role)
{
if (location.empty () != (*role == repository_role::base))
- throw serialization (s.name (), "invalid role");
+ bad_value ("invalid role");
auto r (static_cast<size_t> (*role));
assert (r < repository_role_names.size ());
s.next ("role", repository_role_names[r]);
}
+ bool b (effective_role () == repository_role::base);
+
+ if (url)
+ {
+ if (!b)
+ bad_value ("url not allowed");
+
+ s.next ("url", *url);
+ }
+
+ if (email)
+ {
+ if (!b)
+ bad_value ("email not allowed");
+
+ s.next ("email", *email);
+ }
+
+ if (summary)
+ {
+ if (!b)
+ bad_value ("summary not allowed");
+
+ s.next ("summary", *summary);
+ }
+
+ if (description)
+ {
+ if (!b)
+ bad_value ("description not allowed");
+
+ s.next ("description", *description);
+ }
+
s.next ("", ""); // End of manifest.
}