aboutsummaryrefslogtreecommitdiff
path: root/bpkg
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-06-19 20:28:38 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2019-06-21 18:39:22 +0300
commit6e5e3972542baa1c715e13a36c1144f148c6320b (patch)
treebc4e26e743c77dae3fe774d9a1adc8ca486fba1a /bpkg
parentf2569bd8b6cff7f17ae71035cc3d4e86b2fc0cc4 (diff)
Consider only latest revisions for git repository location default set
Diffstat (limited to 'bpkg')
-rw-r--r--bpkg/fetch-git.cxx36
-rw-r--r--bpkg/repository-types.cli3
2 files changed, 34 insertions, 5 deletions
diff --git a/bpkg/fetch-git.cxx b/bpkg/fetch-git.cxx
index 5ffc9a6..689a927 100644
--- a/bpkg/fetch-git.cxx
+++ b/bpkg/fetch-git.cxx
@@ -1073,13 +1073,41 @@ namespace bpkg
caps ();
refs::search_result r;
+ vector<standard_version> vs; // Parallel to search_result.
+
for (const ref& rf: load_refs (co, url ()))
{
- if (!rf.peeled &&
- rf.name.compare (0, 11, "refs/tags/v") == 0 &&
+ if (!rf.peeled && rf.name.compare (0, 11, "refs/tags/v") == 0)
+ {
+ optional<standard_version> v (
parse_standard_version (string (rf.name, 11),
- standard_version::allow_stub))
- r.push_back (rf);
+ standard_version::allow_stub));
+
+ if (v)
+ {
+ // Add this tag reference into the default set if it doesn't
+ // contain this version yet or replace the existing reference if
+ // this revision is greater.
+ //
+ auto i (find_if (
+ vs.begin (), vs.end (),
+ [&v] (const standard_version& i)
+ {
+ return i.compare (*v, true /* ignore_revision */) == 0;
+ }));
+
+ if (i == vs.end ())
+ {
+ r.push_back (rf);
+ vs.push_back (move (*v));
+ }
+ else if (*i < *v)
+ {
+ r[i - vs.begin ()] = rf;
+ *i = move (*v);
+ }
+ }
+ }
}
return r;
diff --git a/bpkg/repository-types.cli b/bpkg/repository-types.cli
index 6100e72..29edb95 100644
--- a/bpkg/repository-types.cli
+++ b/bpkg/repository-types.cli
@@ -77,7 +77,8 @@ for all of them could be prohibitively expensive. As a result, by default,
only advertised tags in the \cb{refs/tags/v*} form where the part after \cb{v}
is also a valid \l{b#module-version standard version} are considered to be
sources of useful package versions. These commits normally correspond to
-released versions and are called the \i{default set}.
+released versions and are called the \i{default set}. Note that only the
+latest revision of each such version is considered.
Instead of the default set, it is possible to provide a custom set of
available versions by specifying one or more commit ids and/or references