diff options
-rw-r--r-- | bpkg/manifest-utility.cxx | 18 | ||||
-rw-r--r-- | tests/rep-fetch.test | 37 |
2 files changed, 42 insertions, 13 deletions
diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx index a2b817d..50ee4e8 100644 --- a/bpkg/manifest-utility.cxx +++ b/bpkg/manifest-utility.cxx @@ -155,19 +155,25 @@ namespace bpkg { size_t p (s.find (':')); - // If it has no scheme or the scheme looks like that of a URL, then this - // is not a canonical name. + // If it has no scheme, then this is not a canonical name. // - if (p == string::npos || butl::url::traits::find (s, p) != string::npos) + if (p == string::npos) return false; // This is a canonical name if the scheme is convertible to the repository - // type. + // type and is followed by the colon and no more than one slash. + // + // Note that the approach is valid unless we invent the file scheme for the + // canonical name. // try { - to_repository_type (string (s, 0, p)); - return true; + string scheme (s, 0, p); + to_repository_type (scheme); + bool r (!(p + 2 < s.size () && s[p + 1] == '/' && s[p + 2] == '/')); + + assert (!r || scheme != "file"); + return r; } catch (const invalid_argument&) { diff --git a/tests/rep-fetch.test b/tests/rep-fetch.test index f7be436..f0c0e2d 100644 --- a/tests/rep-fetch.test +++ b/tests/rep-fetch.test @@ -321,19 +321,21 @@ $* 2>>/EOE != 0 : dir-rep : +: For dir repository tests we will reuse local git repositories, that have the +: same repository structure. +: +if ($remote != true) { rep_add += --type dir + rep = $canonicalize([dir_path] $out_git/state0) + + +$clone_cfg && $rep_add $rep/libbar.git + : prerequisites : - if ($remote != true) { - # Let's reuse local git repositories that have the same repository - # structure as for dir type. - # - rep = $canonicalize([dir_path] $out_git/state0) - - $clone_root_cfg && $rep_add $rep/libbar.git; + $clone_cfg; $* 2>>"EOE"; fetching dir:($rep/libbar.git) @@ -346,6 +348,27 @@ $* 2>>/EOE != 0 prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) EOO } + + : by-name + : + : Here we, in particular, test that the local repository canonical name + : (dir:/...) is not confused with the repository URL. + : + { + $clone_cfg; + $* 2>!; + + $* "dir:($rep/libbar.git)" 2>>"EOE"; + fetching dir:($rep/libbar.git) + fetching dir:($rep/style-basic.git) \(prerequisite of dir:($rep/libbar.git)\) + 3 package\(s\) in 2 repository\(s\) + EOE + + $rep_list >>"EOO" + dir:($rep/libbar.git) ($rep/libbar.git) + prerequisite dir:($rep/style-basic.git) ($rep/style-basic.git) + EOO + } } : git-rep |