diff options
author | James Moger <james.moger@gitblit.com> | 2014-04-07 22:09:31 -0600 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-07 22:09:31 -0600 |
commit | 90c354f5760edde96d44556f3bc8e9e630777029 (patch) | |
tree | 598d73d3ae22a9128a8a7a292e940220af30767f /src/main/java/com | |
parent | 6f54fd22f1495c3e532048bd256b5fa9cc41da82 (diff) | |
parent | 4263c2da123d241a7d0fe11e777b7bc80dae4af7 (diff) | |
download | gitblit-90c354f5760edde96d44556f3bc8e9e630777029.tar.gz gitblit-90c354f5760edde96d44556f3bc8e9e630777029.zip |
Merged #40 "Fix intermittent NPE in getting commit date in RefModel"
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/gitblit/models/RefModel.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/com/gitblit/models/RefModel.java b/src/main/java/com/gitblit/models/RefModel.java index 6b031ed3..02ba1302 100644 --- a/src/main/java/com/gitblit/models/RefModel.java +++ b/src/main/java/com/gitblit/models/RefModel.java @@ -25,6 +25,8 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevObject;
import org.eclipse.jgit.revwalk.RevTag;
+import com.gitblit.utils.JGitUtils;
+
/**
* RefModel is a serializable model class that represents a tag or branch and
* includes the referenced object.
@@ -50,11 +52,18 @@ public class RefModel implements Serializable, Comparable<RefModel> { if (referencedObject != null) {
if (referencedObject instanceof RevTag) {
RevTag tag = (RevTag) referencedObject;
- if (tag.getTaggerIdent() != null) {
- date = tag.getTaggerIdent().getWhen();
+ PersonIdent tagger = tag.getTaggerIdent();
+ if (tagger != null) {
+ date = tagger.getWhen();
}
} else if (referencedObject instanceof RevCommit) {
- date = ((RevCommit) referencedObject).getCommitterIdent().getWhen();
+ RevCommit commit = (RevCommit) referencedObject;
+ PersonIdent committer = commit.getCommitterIdent();
+ if (committer != null) {
+ date = committer.getWhen();
+ } else {
+ date = JGitUtils.getCommitDate(commit);
+ }
}
}
return date;
|