From dfcbb65ed9b65f392fc250cb91124e4793b49c14 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 5 Jul 2018 13:54:08 +0300 Subject: Guess repository type for relative locations and consider git type for all locations with .git extension --- libbpkg/manifest.cxx | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'libbpkg/manifest.cxx') diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index dc488de..af2a889 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -2062,13 +2062,14 @@ namespace bpkg } case repository_protocol::http: case repository_protocol::https: - { - return url.path->extension () == "git" - ? repository_type::git - : repository_type::pkg; - } case repository_protocol::file: { + if (url.path->extension () == "git") + return repository_type::git; + + if (url.scheme != repository_protocol::file) // HTTP(S)? + return repository_type::pkg; + return local && dir_exists (path_cast (*url.path) / dir_path (".git")) ? repository_type::git @@ -2751,25 +2752,8 @@ namespace bpkg { repository_url u (move (location->value)); - // If the prerequisite repository type is not specified explicitly then - // we consider it to be the base repository type for the relative - // location or guess it otherwise. - // if (!type) - { - if (u.scheme == repository_protocol::file && u.path->relative ()) - { - type = base_type; - - // Strip the URL fragment if the base repository type is dir (see - // the Repository Manifest documentation for the gory details). - // - if (base_type == repository_type::dir) - u.fragment = nullopt; - } - else - type = guess_type (u, false); // Can't throw. - } + type = guess_type (u, false); // Can't throw. // Call prerequisite repository location constructor, do not amend // relative path. -- cgit v1.1