Skip to content

Commit 1238f63

Browse files
committed
Restore old logic with instant
1 parent fb987a7 commit 1238f63

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main/java/pl/project13/core/jgit/dummy/DatedRevTag.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
import org.eclipse.jgit.lib.AnyObjectId;
2121
import org.eclipse.jgit.revwalk.RevTag;
22+
2223
import java.time.Instant;
24+
import java.time.temporal.ChronoUnit;
2325

2426
public class DatedRevTag {
2527

@@ -28,11 +30,13 @@ public class DatedRevTag {
2830
public final Instant date;
2931

3032
public DatedRevTag(RevTag tag) {
31-
this(tag.getId(), tag.getTagName(), (tag.getTaggerIdent() != null) ? tag.getTaggerIdent().getWhen().toInstant() : Instant.now());
33+
this(tag.getId(), tag.getTagName(), tag.getTaggerIdent() != null
34+
? tag.getTaggerIdent().getWhen().toInstant()
35+
: nowMinusYears(1900));
3236
}
3337

3438
public DatedRevTag(AnyObjectId id, String tagName) {
35-
this(id, tagName, Instant.now());
39+
this(id, tagName, nowMinusYears(2000));
3640
}
3741

3842
public DatedRevTag(AnyObjectId id, String tagName, Instant date) {
@@ -41,6 +45,11 @@ public DatedRevTag(AnyObjectId id, String tagName, Instant date) {
4145
this.date = date;
4246
}
4347

48+
static Instant nowMinusYears(final int years) {
49+
// Instant does not support operations using > DAYS
50+
return Instant.now().minus(years * 365L, ChronoUnit.DAYS);
51+
}
52+
4453
@Override
4554
public String toString() {
4655
return "DatedRevTag{" +

0 commit comments

Comments
 (0)