use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class TimeCache method getTime.
Long getTime(final RevWalk walk, final ObjectId id) throws IOException {
try {
return cache.get(id, () -> {
RevObject o = walk.parseAny(id);
while (o instanceof RevTag) {
RevTag tag = (RevTag) o;
PersonIdent ident = tag.getTaggerIdent();
if (ident != null) {
return ident.getWhen().getTime() / 1000;
}
o = tag.getObject();
walk.parseHeaders(o);
}
if (o.getType() == Constants.OBJ_COMMIT) {
return Long.valueOf(((RevCommit) o).getCommitTime());
}
return Long.MIN_VALUE;
});
} catch (ExecutionException e) {
Throwables.throwIfInstanceOf(e.getCause(), IOException.class);
throw new IOException(e);
}
}
use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class IdentRevFilterTest method caseSensitiveName.
@Test
public void caseSensitiveName() throws Exception {
IdentRevFilter filter = IdentRevFilter.author("eSt");
assertThat(filter.matchesPerson(new PersonIdent("est", "null@google.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("Establish", "null@google.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("tESt", "null@google.com"))).isFalse();
assertThat(filter.matchesPerson(new PersonIdent("tesTing", "null@google.com"))).isFalse();
}
use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class IdentRevFilterTest method matchesEmailLocalPart.
@Test
public void matchesEmailLocalPart() throws Exception {
IdentRevFilter filter = IdentRevFilter.author("eSt");
assertThat(filter.matchesPerson(new PersonIdent("null", "eSt@google.com"))).isTrue();
assertThat(filter.matchesPerson(new PersonIdent("null", "eStablish@google.com"))).isTrue();
assertThat(filter.matchesPerson(new PersonIdent("null", "teSt@google.com"))).isTrue();
assertThat(filter.matchesPerson(new PersonIdent("null", "teSting@google.com"))).isTrue();
}
use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class DateFormatterTest method newIdent.
private PersonIdent newIdent(String whenStr, String tzStr) throws ParseException {
whenStr += " " + tzStr;
Date when = GitDateParser.parse(whenStr, null);
TimeZone tz = getTimeZone("GMT" + tzStr);
PersonIdent ident = new PersonIdent("A User", "user@example.com", when, tz);
// PersonIdent.toString() uses its own format with "d" instead of "dd",
// hence the mismatches in 2 vs. 02 above. Nonetheless I think this sanity
// check is useful enough to keep around.
assertThat(ident.toString()).isEqualTo("PersonIdent[A User, user@example.com, " + whenStr + "]");
return ident;
}
use of org.eclipse.jgit.lib.PersonIdent in project gitiles by GerritCodeReview.
the class DateFormatterTest method isoIncludingTimeZone.
@Test
public void isoIncludingTimeZone() throws Exception {
PersonIdent ident = newIdent("Mon Jan 2 15:04:05 2006", "-0700");
DateFormatter df = new DateFormatter(Optional.empty(), ISO);
assertThat(df.format(ident)).isEqualTo("2006-01-02 15:04:05 -0700");
}
Aggregations