diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-11-14 22:19:50 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-11-15 20:40:40 +0300 |
commit | 2667fad8bf6e7ef6ef1894ab49a3bdc5cc858607 (patch) | |
tree | f3f6650da4c3a4b3b8a5c06343c82646be84507f | |
parent | d622f34a8c6ad0e71618f75a02787589b21d795c (diff) |
Add support for repository location compound schemes (git+https, etc)
-rw-r--r-- | load/load.cxx | 18 | ||||
-rw-r--r-- | mod/mod-ci.cxx | 17 | ||||
-rw-r--r-- | mod/mod-package-version-details.cxx | 2 | ||||
-rw-r--r-- | mod/options.cli | 6 | ||||
-rw-r--r-- | mod/types-parsers.cxx | 8 | ||||
-rw-r--r-- | mod/types-parsers.hxx | 6 |
6 files changed, 22 insertions, 35 deletions
diff --git a/load/load.cxx b/load/load.cxx index 97cd133..c032137 100644 --- a/load/load.cxx +++ b/load/load.cxx @@ -94,7 +94,7 @@ using internal_repositories = vector<internal_repository>; // will allow handling CI requests for bpkg repositories. // // The current thinking is that the CI handler will be able to "suggest" -// this using (the planned) cache:file+dir:// form. +// this using (the planned) cache:dir+file:// form. // static internal_repositories load_repositories (path p) @@ -138,10 +138,7 @@ load_repositories (path p) try { - repository_url u (tl[i].value); - - r.location = repository_location (u, - guess_type (u, false /* local */)); + r.location = repository_location (tl[i].value); } catch (const invalid_argument& e) { @@ -277,16 +274,17 @@ changed (const string& tenant, database& db) { strings names; - for (auto& r: repos) + for (const internal_repository& r: repos) { shared_ptr<repository> pr ( db.find<repository> (repository_id (tenant, r.location.canonical_name ()))); - if (pr == nullptr || r.location.string () != pr->location.string () || - r.display_name != pr->display_name || - r.cache_location.path () != pr->cache_location.path () || - file_mtime (r.packages_path ()) != pr->packages_timestamp || + if (pr == nullptr || + r.location.string () != pr->location.string () || + r.display_name != pr->display_name || + r.cache_location.path () != pr->cache_location.path () || + file_mtime (r.packages_path ()) != pr->packages_timestamp || file_mtime (r.repositories_path ()) != pr->repositories_timestamp || !pr->internal) return true; diff --git a/mod/mod-ci.cxx b/mod/mod-ci.cxx index e16a1a1..e0b35dd 100644 --- a/mod/mod-ci.cxx +++ b/mod/mod-ci.cxx @@ -222,23 +222,12 @@ handle (request& rq, response& rs) return true; } - // Parse and verify the remote repository location. + // Verify the remote repository location. // - repository_location rl; + const repository_location rl (params.repository ()); - try - { - const repository_url& u (params.repository ()); - - if (u.empty () || u.scheme == repository_protocol::file) - throw invalid_argument (""); - - rl = repository_location (u, guess_type (u, false /* local */)); - } - catch (const invalid_argument&) - { + if (rl.empty () || rl.local ()) return respond_manifest (400, "invalid repository location"); - } // Verify the package name[/version] arguments. // diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index f9d346e..bafe8f7 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -208,7 +208,7 @@ handle (request& rq, response& rs) { assert (pkg->location); - s << TR_DOWNLOAD (rl.string () + "/" + pkg->location->string ()); + s << TR_DOWNLOAD (rl.url ().string () + "/" + pkg->location->string ()); } if (pkg->fragment) diff --git a/mod/options.cli b/mod/options.cli index c78af73..8020f95 100644 --- a/mod/options.cli +++ b/mod/options.cli @@ -2,7 +2,7 @@ // copyright : Copyright (c) 2014-2018 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -include <libbpkg/manifest.hxx>; // repository_url +include <libbpkg/manifest.hxx>; // repository_location include <web/xhtml-fragment.hxx>; @@ -765,12 +765,12 @@ namespace brep // class ci { - // Package repository URL. + // Package repository location. // // Note that the ci parameter is renamed to '_' by the root handler (see // the request_proxy class for details). // - bpkg::repository_url repository | _; + bpkg::repository_location repository | _; // Package names/versions. // diff --git a/mod/types-parsers.cxx b/mod/types-parsers.cxx index e40a777..1467bf6 100644 --- a/mod/types-parsers.cxx +++ b/mod/types-parsers.cxx @@ -51,10 +51,10 @@ namespace brep parse_path (x, s); } - // Parse repository_url. + // Parse repository_location. // - void parser<repository_url>:: - parse (repository_url& x, bool& xs, scanner& s) + void parser<repository_location>:: + parse (repository_location& x, bool& xs, scanner& s) { xs = true; @@ -67,7 +67,7 @@ namespace brep try { - x = repository_url (v); + x = repository_location (v); } catch (const invalid_argument&) { diff --git a/mod/types-parsers.hxx b/mod/types-parsers.hxx index 36128d9..87ea8ed 100644 --- a/mod/types-parsers.hxx +++ b/mod/types-parsers.hxx @@ -8,7 +8,7 @@ #ifndef MOD_TYPES_PARSERS_HXX #define MOD_TYPES_PARSERS_HXX -#include <libbpkg/manifest.hxx> // repository_url +#include <libbpkg/manifest.hxx> // repository_location #include <web/xhtml-fragment.hxx> @@ -41,10 +41,10 @@ namespace brep }; template <> - struct parser<bpkg::repository_url> + struct parser<bpkg::repository_location> { static void - parse (bpkg::repository_url&, bool&, scanner&); + parse (bpkg::repository_location&, bool&, scanner&); }; template <> |