Skip to content

Commit 4c94f88

Browse files
committed
libgit2: ensure original tag is used for TS lookup
This adds an additional selection candidate, to ensure test flakiness happens more often. Signed-off-by: Hidde Beydals <[email protected]>
1 parent b35d7d8 commit 4c94f88

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

pkg/git/libgit2/checkout.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (c *CheckoutSemVer) Checkout(ctx context.Context, path, url string, auth *g
225225
// versions into a chronological order. This is especially important for
226226
// versions that differ only by build metadata, because it is not considered
227227
// a part of the comparable version in Semver
228-
return tagTimestamps[left.String()].Before(tagTimestamps[right.String()])
228+
return tagTimestamps[left.Original()].Before(tagTimestamps[right.Original()])
229229
})
230230
v := matchedVersions[len(matchedVersions)-1]
231231
t := v.Original()

pkg/git/libgit2/checkout_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,19 @@ func TestCheckoutTagSemVer_Checkout(t *testing.T) {
229229
{
230230
tag: "v0.1.0+build-1",
231231
annotated: true,
232-
commitTime: now.Add(1 * time.Minute),
233-
tagTime: now.Add(1 * time.Hour), // This should be ignored during TS comparisons
232+
commitTime: now.Add(10 * time.Minute),
233+
tagTime: now.Add(2 * time.Hour), // This should be ignored during TS comparisons
234234
},
235235
{
236236
tag: "v0.1.0+build-2",
237237
annotated: false,
238-
commitTime: now.Add(2 * time.Minute),
238+
commitTime: now.Add(30 * time.Minute),
239+
},
240+
{
241+
tag: "v0.1.0+build-3",
242+
annotated: true,
243+
commitTime: now.Add(1 * time.Hour),
244+
tagTime: now.Add(1 * time.Hour), // This should be ignored during TS comparisons
239245
},
240246
{
241247
tag: "0.2.0",
@@ -258,7 +264,7 @@ func TestCheckoutTagSemVer_Checkout(t *testing.T) {
258264
{
259265
name: "Orders by SemVer and timestamp",
260266
constraint: "<0.2.0",
261-
expectTag: "v0.1.0+build-2",
267+
expectTag: "v0.1.0+build-3",
262268
},
263269
{
264270
name: "Errors without match",

0 commit comments

Comments
 (0)