aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-07-04 22:10:38 +0300
committerBoris Kolpackov <boris@codesynthesis.com>2018-07-05 08:49:59 +0200
commit9be433ac34057a2c9c1757ec41f8b3f6361f98dc (patch)
tree053bc111fd525086c29343195bea595eaca4d43b
parentadefc9b14d8940299a0c6b478de8b66566978d10 (diff)
Strip .git extension for non-existent local prerequisite location
If the local prerequisite git repository having the .git extension doesn't exist but the one without the extension does, then strip the extension from the location.
-rw-r--r--bpkg/rep-fetch.cxx21
-rw-r--r--doc/manual.cli7
-rw-r--r--tests/rep-fetch.test33
3 files changed, 60 insertions, 1 deletions
diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx
index 2de6a01..b905a7b 100644
--- a/bpkg/rep-fetch.cxx
+++ b/bpkg/rep-fetch.cxx
@@ -533,6 +533,27 @@ namespace bpkg
<< "': " << e <<
info << "base repository location is " << rl;
}
+
+ // If the local prerequisite git repository having the .git extension
+ // doesn't exist but the one without the extension does, then we
+ // strip the extension from the location.
+ //
+ if (l.local () &&
+ l.type () == repository_type::git &&
+ l.path ().extension () == "git")
+ {
+ dir_path d (path_cast<dir_path> (l.path ()));
+
+ if (!exists (d) && exists (d.base () / dir_path (".git")))
+ {
+ repository_url u (l.url ());
+
+ assert (u.path);
+ u.path->make_base ();
+
+ l = repository_location (u, l.type ());
+ }
+ }
}
}
}
diff --git a/doc/manual.cli b/doc/manual.cli
index 16485df..5e2effe 100644
--- a/doc/manual.cli
+++ b/doc/manual.cli
@@ -1110,7 +1110,12 @@ already know the location of the base repository.} If the location is a
relative path, then it is treated as relative to the base repository location.
For the \cb{git} repository type the relative location does not inherit the
-URL fragment from the base repository.
+URL fragment from the base repository. Note also that the remote \cb{git}
+repository locations normally have the \cb{.git} extension that is stripped
+when a repository is cloned locally. To make the relative locations usable in
+both contexts, the \cb{.git} extension should be ignored if the local
+prerequisite repository with the extension does not exist while the one
+without the extension does.
For the \cb{dir} repository type the relative location may also contain the
URL fragment to make the same repository information usable in case the base
diff --git a/tests/rep-fetch.test b/tests/rep-fetch.test
index bd91ebf..9543045 100644
--- a/tests/rep-fetch.test
+++ b/tests/rep-fetch.test
@@ -721,6 +721,39 @@ else
}
}
+ : strip-ext
+ :
+ : Test that if the local prerequisite git repository having the .git
+ : extension does not exist but the one without the extension does, then
+ : it is picked up by rep-fetch.
+ :
+ if ($remote != true)
+ {
+ cp -r $out_git/state0/libbar.git libbar.git;
+ cp -r $out_git/state0/style-basic.git style-basic;
+
+ $clone_root_cfg;
+
+ rep = ($cxx.target.class != 'windows' \
+ ? "file:$~" \
+ : "file:/$regex.replace($~, '\\', '/')");
+
+ $* "$rep/libbar.git#master" 2>>~%EOE% &cfg/.bpkg/repos/*/***;
+ %added git:.+libbar#master%
+ %querying .+libbar\.git%
+ %fetching from .+libbar\.git%
+ %fetching git:.+style-basic#stable \(prerequisite of git:.+libbar#master\)%
+ %querying .+style-basic%
+ %fetching from .+style-basic%
+ 3 package(s) in 2 repository(s)
+ EOE
+
+ $rep_list >>~%EOO%
+ %git:.+libbar#master file:.+libbar\.git#master%
+ % prerequisite git:.+style-basic#stable file:.+style-basic#stable \(heads/master\)%
+ EOO
+ }
+
: checkout-submodules
:
: Test that if some of the packages are located in the repository