ListTags: Fix NPE when annotated/signed tag has no tagger info
The implementation assumed that annotated/signed tags would always have a tagger, but this is not the case as we can see with the tag v0.99 on the git project [1], and this causes a NullPointerException when trying to convert to a GitPerson. Add a null check. Also update the documentation accordingly. [1] http://git.kernel.org/cgit/git/git.git/tag/?h=v0.99 Change-Id: I7dcb98a845d9a9e83c60d32f7ae5b51eba38bab6
This commit is contained in:
parent
830cf983e7
commit
c9f5a5ab76
@ -2329,7 +2329,7 @@ points. For annotated tags, the revision of the tag object.
|
||||
tag points.
|
||||
|`message`|Only set for annotated tags.|The tag message. For signed tags, includes
|
||||
the signature.
|
||||
|`tagger`|Only set for annotated tags.|The tagger as a
|
||||
|`tagger`|Only set for annotated tags, if present in the tag.|The tagger as a
|
||||
link:rest-api-changes.html#git-person-info[GitPersonInfo] entity.
|
||||
|=========================
|
||||
|
||||
|
@ -34,6 +34,7 @@ import com.google.inject.Singleton;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.PersonIdent;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevObject;
|
||||
@ -132,14 +133,16 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
throws MissingObjectException, IOException {
|
||||
RevObject object = rw.parseAny(ref.getObjectId());
|
||||
if (object instanceof RevTag) {
|
||||
RevTag tag = (RevTag)object;
|
||||
// Annotated or signed tag
|
||||
RevTag tag = (RevTag)object;
|
||||
PersonIdent tagger = tag.getTaggerIdent();
|
||||
return new TagInfo(
|
||||
ref.getName(),
|
||||
tag.getName(),
|
||||
tag.getObject().getName(),
|
||||
tag.getFullMessage().trim(),
|
||||
CommonConverters.toGitPerson(tag.getTaggerIdent()));
|
||||
tagger != null ?
|
||||
CommonConverters.toGitPerson(tag.getTaggerIdent()) : null);
|
||||
} else {
|
||||
// Lightweight tag
|
||||
return new TagInfo(
|
||||
|
Loading…
Reference in New Issue
Block a user