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 /mod | |
parent | d622f34a8c6ad0e71618f75a02787589b21d795c (diff) |
Add support for repository location compound schemes (git+https, etc)
Diffstat (limited to 'mod')
-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 |
5 files changed, 14 insertions, 25 deletions
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 <> |