aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2019-06-19 17:28:38 (GMT)
committerKaren Arutyunov <karen@codesynthesis.com>2019-06-21 15:39:22 (GMT)
commit6e5e3972542baa1c715e13a36c1144f148c6320b (patch)
treebc4e26e743c77dae3fe774d9a1adc8ca486fba1a
parentf2569bd8b6cff7f17ae71035cc3d4e86b2fc0cc4 (diff)
Consider only latest revisions for git repository location default set
-rw-r--r--bpkg/fetch-git.cxx36
-rw-r--r--bpkg/repository-types.cli3
-rwxr-xr-xtests/common/git/init27
-rw-r--r--tests/common/git/state0/libbar.tarbin174080 -> 184320 bytes
-rw-r--r--tests/common/git/state0/libfoo.tarbin450560 -> 450560 bytes
-rw-r--r--tests/common/git/state0/libfox.tarbin245760 -> 245760 bytes
-rw-r--r--tests/common/git/state0/links.tarbin276480 -> 276480 bytes
-rw-r--r--tests/common/git/state0/style-basic.tarbin81920 -> 81920 bytes
-rw-r--r--tests/common/git/state0/style.tarbin143360 -> 143360 bytes
-rw-r--r--tests/common/git/state1/libbaz.tarbin61440 -> 61440 bytes
-rw-r--r--tests/common/git/state1/libfoo.tarbin512000 -> 512000 bytes
-rw-r--r--tests/common/git/state1/libfox.tarbin245760 -> 245760 bytes
-rw-r--r--tests/common/git/state1/style-basic.tarbin81920 -> 81920 bytes
-rw-r--r--tests/common/git/state1/style.tarbin143360 -> 143360 bytes
-rw-r--r--tests/rep-fetch.testscript13
-rw-r--r--tests/rep-info.testscript8
16 files changed, 78 insertions, 9 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
diff --git a/tests/common/git/init b/tests/common/git/init
index 8cac2da..81479a8 100755
--- a/tests/common/git/init
+++ b/tests/common/git/init
@@ -113,11 +113,38 @@ git -C style-basic.git checkout master
# Create master branch for libbar.git.
#
git -C libbar.git init
+
+cat <<EOF >libbar.git/libbar/manifest
+: 1
+name: libbar
+version: 1.0.0
+summary: libbar
+license: MIT
+description-file: README
+url: http://example.org/libbar
+email: pkg@example.org
+depends: style-basic >= $
+EOF
+
git -C libbar.git add '*'
git -C libbar.git commit -am 'Create'
git -C libbar.git tag -a 'v1.0.0' -m 'Tag version 1.0.0'
+
git -C libbar.git submodule add -b stable ../style-basic.git extras
+cat <<EOF >libbar.git/libbar/manifest
+: 1
+name: libbar
+version: 1.0.0+1
+summary: libbar
+license: MIT
+description-file: README
+url: http://example.org/libbar
+email: pkg@example.org
+depends: style-basic >= $
+EOF
+
git -C libbar.git commit -am 'Add extras'
+git -C libbar.git tag -a 'v1.0.0+1' -m 'Tag version 1.0.0+1'
# Create master branch for libfoo.git, adding style.git and libbar.git as
# submodules.
diff --git a/tests/common/git/state0/libbar.tar b/tests/common/git/state0/libbar.tar
index cf00747..ea4d296 100644
--- a/tests/common/git/state0/libbar.tar
+++ b/tests/common/git/state0/libbar.tar
Binary files differ
diff --git a/tests/common/git/state0/libfoo.tar b/tests/common/git/state0/libfoo.tar
index 05281ee..d30ab31 100644
--- a/tests/common/git/state0/libfoo.tar
+++ b/tests/common/git/state0/libfoo.tar
Binary files differ
diff --git a/tests/common/git/state0/libfox.tar b/tests/common/git/state0/libfox.tar
index b024532..50b9840 100644
--- a/tests/common/git/state0/libfox.tar
+++ b/tests/common/git/state0/libfox.tar
Binary files differ
diff --git a/tests/common/git/state0/links.tar b/tests/common/git/state0/links.tar
index 3769fd1..f8a7efd 100644
--- a/tests/common/git/state0/links.tar
+++ b/tests/common/git/state0/links.tar
Binary files differ
diff --git a/tests/common/git/state0/style-basic.tar b/tests/common/git/state0/style-basic.tar
index 01eadbc..aa23cf0 100644
--- a/tests/common/git/state0/style-basic.tar
+++ b/tests/common/git/state0/style-basic.tar
Binary files differ
diff --git a/tests/common/git/state0/style.tar b/tests/common/git/state0/style.tar
index 042684e..9ab3367 100644
--- a/tests/common/git/state0/style.tar
+++ b/tests/common/git/state0/style.tar
Binary files differ
diff --git a/tests/common/git/state1/libbaz.tar b/tests/common/git/state1/libbaz.tar
index 5238b4a..420a984 100644
--- a/tests/common/git/state1/libbaz.tar
+++ b/tests/common/git/state1/libbaz.tar
Binary files differ
diff --git a/tests/common/git/state1/libfoo.tar b/tests/common/git/state1/libfoo.tar
index c0e7523..c827226 100644
--- a/tests/common/git/state1/libfoo.tar
+++ b/tests/common/git/state1/libfoo.tar
Binary files differ
diff --git a/tests/common/git/state1/libfox.tar b/tests/common/git/state1/libfox.tar
index e502974..95e2e07 100644
--- a/tests/common/git/state1/libfox.tar
+++ b/tests/common/git/state1/libfox.tar
Binary files differ
diff --git a/tests/common/git/state1/style-basic.tar b/tests/common/git/state1/style-basic.tar
index 1ef7399..f59e67e 100644
--- a/tests/common/git/state1/style-basic.tar
+++ b/tests/common/git/state1/style-basic.tar
Binary files differ
diff --git a/tests/common/git/state1/style.tar b/tests/common/git/state1/style.tar
index 2a0120b..a627bd5 100644
--- a/tests/common/git/state1/style.tar
+++ b/tests/common/git/state1/style.tar
Binary files differ
diff --git a/tests/rep-fetch.testscript b/tests/rep-fetch.testscript
index cd1c919..d347066 100644
--- a/tests/rep-fetch.testscript
+++ b/tests/rep-fetch.testscript
@@ -1003,6 +1003,19 @@ else
1 package(s) in 1 repository(s)
EOE
}
+
+ : latest-revision
+ :
+ {
+ $clone_root_cfg;
+
+ $* "$rep_git/state0/libbar.git" 2>>~%EOE%;
+ %.+
+ 3 package(s) in 2 repository(s)
+ EOE
+
+ $pkg_status libbar >'libbar available 1.0.0+1'
+ }
}
}
}
diff --git a/tests/rep-info.testscript b/tests/rep-info.testscript
index 1a28dd9..822dada 100644
--- a/tests/rep-info.testscript
+++ b/tests/rep-info.testscript
@@ -127,7 +127,7 @@ $* --name $rep/testing >"pkg:build2.org/rep-info/testing ($rep/testing)"
$* --type dir "state0/libbar.git" >>~%EOO%d;
: 1
name: libbar
- version: 1.0.0
+ version: 1.0.0+1
summary: libbar
license: MIT
description: \
@@ -156,7 +156,7 @@ $* --name $rep/testing >"pkg:build2.org/rep-info/testing ($rep/testing)"
$* "$rep_git/state0/libbar.git#master" >>~%EOO%d 2>!
: 1
name: libbar
- version: 1.0.0
+ version: 1.0.0+1
summary: libbar
license: MIT
description: \
@@ -311,7 +311,7 @@ else
%git:.+libbar#master .+libbar.git#master%
%prerequisite git:.+style-basic#stable .+style-basic.git#stable%
- libbar/1.0.0
+ libbar/1.0.0+1
libmbar/1.0.0
EOO
@@ -331,7 +331,7 @@ else
$* -p --manifest "$rep/libbar.git#master" >>~%EOO%d
: 1
name: libbar
- version: 1.0.0
+ version: 1.0.0+1
summary: libbar
license: MIT
description-file: README