From 2667fad8bf6e7ef6ef1894ab49a3bdc5cc858607 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 14 Nov 2018 22:19:50 +0300 Subject: Add support for repository location compound schemes (git+https, etc) --- mod/mod-ci.cxx | 17 +++-------------- mod/mod-package-version-details.cxx | 2 +- mod/options.cli | 6 +++--- mod/types-parsers.cxx | 8 ++++---- mod/types-parsers.hxx | 6 +++--- 5 files changed, 14 insertions(+), 25 deletions(-) (limited to 'mod') 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 ; // repository_url +include ; // repository_location include ; @@ -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:: - parse (repository_url& x, bool& xs, scanner& s) + void parser:: + 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 // repository_url +#include // repository_location #include @@ -41,10 +41,10 @@ namespace brep }; template <> - struct parser + struct parser { static void - parse (bpkg::repository_url&, bool&, scanner&); + parse (bpkg::repository_location&, bool&, scanner&); }; template <> -- cgit v1.1