From 6e5e3972542baa1c715e13a36c1144f148c6320b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 19 Jun 2019 20:28:38 +0300 Subject: Consider only latest revisions for git repository location default set --- bpkg/fetch-git.cxx | 36 ++++++++++++++++++++++++++++++++---- bpkg/repository-types.cli | 3 ++- 2 files changed, 34 insertions(+), 5 deletions(-) (limited to 'bpkg') 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 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 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 -- cgit v1.1