Map<String, Ref> tags = repository.getRefDatabase().getRefs(
Constants.R_TAGS);
for (Ref tagRef : tags.values()) {
RevObject any = rw.parseAny(repository.resolve(tagRef.getName()));
if (any instanceof RevTag) {
RevTag tag = (RevTag) any;
if (tag.getObject().name().equals(commitId)) {
Date timestamp;
if (tag.getTaggerIdent() != null) {
timestamp = tag.getTaggerIdent().getWhen();
} else {
try {
RevCommit commit = rw.parseCommit(tag.getObject());
timestamp = commit.getCommitterIdent().getWhen();
} catch (IncorrectObjectTypeException e) {
// not referencing a comit.
timestamp = null;
}