aboutsummaryrefslogtreecommitdiff
path: root/libbpkg
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-02-22 17:35:20 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-02-22 17:35:20 +0300
commitf27e01c849a88803614f521f601efecca1da649c (patch)
treeb64d3b73646d0715837ef3db2ad6f031f258bb50 /libbpkg
parent34dd55af8432455c25cfe659841273bcd2b8e76a (diff)
Add repository URL fragment to canonical name
Diffstat (limited to 'libbpkg')
-rw-r--r--libbpkg/manifest.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx
index d58b6d8..8683037 100644
--- a/libbpkg/manifest.cxx
+++ b/libbpkg/manifest.cxx
@@ -11,7 +11,7 @@
#include <cstring> // strncmp(), strcmp()
#include <utility> // move()
#include <cstdint> // uint16_t, UINT16_MAX
-#include <algorithm> // find(), find_if_not(), replace()
+#include <algorithm> // find(), find_if_not(), find_first_of(), replace()
#include <stdexcept> // invalid_argument
#include <libbutl/path.mxx>
@@ -2016,11 +2016,13 @@ namespace bpkg
url_ = move (u);
// Set canonical name to the base location canonical name 'bpkg:<host>'
- // part. The path part of the canonical name is calculated below.
+ // part. The '<path>[#<fragment>]' part of the canonical name is
+ // calculated below.
//
if (b.remote ())
canonical_name_ =
- b.canonical_name_.substr (0, b.canonical_name_.find ("/"));
+ b.canonical_name_.substr (0,
+ b.canonical_name_.find_first_of ("/#"));
}
}
@@ -2088,7 +2090,7 @@ namespace bpkg
string cp (sp.relative () ? sp.posix_string () : sp.string ());
- // Don't allow empty canonical names.
+ // Don't allow canonical names without both host and path parts.
//
if (canonical_name_.empty () && cp.empty ())
throw invalid_argument ("empty repository name");
@@ -2107,6 +2109,12 @@ namespace bpkg
}
canonical_name_ += cp;
+
+ if (url_.fragment)
+ {
+ canonical_name_ += '#';
+ canonical_name_ += *url_.fragment;
+ }
}
// git_reference