Class RevTag
- java.lang.Object
-
- org.eclipse.jgit.lib.AnyObjectId
-
- org.eclipse.jgit.lib.ObjectId
-
- org.eclipse.jgit.lib.ObjectIdOwnerMap.Entry
-
- org.eclipse.jgit.revwalk.RevObject
-
- org.eclipse.jgit.revwalk.RevTag
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AnyObjectId>
public class RevTag extends RevObject
An annotated tag.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RevTag(AnyObjectId id)
Create a new tag reference.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disposeBody()
Discard the message buffer to reduce memory usage.java.lang.String
getFullMessage()
Parse the complete tag message and decode it to a string.RevObject
getObject()
Get a reference to the object this tag was placed on.java.lang.String
getShortMessage()
Parse the tag message and return the first "line" of it.PersonIdent
getTaggerIdent()
Parse the tagger identity from the raw buffer.java.lang.String
getTagName()
Get the name of this tag, from the tag header.int
getType()
Get Git object type.private java.nio.charset.Charset
guessEncoding()
static RevTag
parse(byte[] raw)
Parse an annotated tag from its canonical format.static RevTag
parse(RevWalk rw, byte[] raw)
Parse an annotated tag from its canonical format.(package private) void
parseBody(RevWalk walk)
(package private) void
parseCanonical(RevWalk walk, byte[] rawTag)
(package private) void
parseHeaders(RevWalk walk)
-
Methods inherited from class org.eclipse.jgit.revwalk.RevObject
add, add, appendCoreFlags, getId, has, hasAll, hasAny, remove, remove, toString
-
Methods inherited from class org.eclipse.jgit.lib.ObjectId
equals, fromRaw, fromRaw, fromRaw, fromRaw, fromString, fromString, isId, toObjectId, toString, zeroId
-
-
-
-
Field Detail
-
object
private RevObject object
-
buffer
private byte[] buffer
-
tagName
private java.lang.String tagName
-
-
Constructor Detail
-
RevTag
protected RevTag(AnyObjectId id)
Create a new tag reference.- Parameters:
id
- object name for the tag.
-
-
Method Detail
-
parse
public static RevTag parse(byte[] raw) throws CorruptObjectException
Parse an annotated tag from its canonical format. This method constructs a temporary revision pool, parses the tag as supplied, and returns it to the caller. Since the tag was built inside of a private revision pool its object pointer will be initialized, but will not have its headers loaded. Applications are discouraged from using this API. Callers usually need more than one object. UseRevWalk.parseTag(AnyObjectId)
to obtain a RevTag from an existing repository.- Parameters:
raw
- the canonical formatted tag to be parsed.- Returns:
- the parsed tag, in an isolated revision pool that is not available to the caller.
- Throws:
CorruptObjectException
- the tag contains a malformed header that cannot be handled.
-
parse
public static RevTag parse(RevWalk rw, byte[] raw) throws CorruptObjectException
Parse an annotated tag from its canonical format.This method inserts the tag directly into the caller supplied revision pool, making it appear as though the tag exists in the repository, even if it doesn't. The repository under the pool is not affected.
The body of the tag (message, tagger, signature) is always retained in the returned
RevTag
, even if the suppliedRevWalk
has been configured withsetRetainBody(false)
.- Parameters:
rw
- the revision pool to allocate the tag within. The tag's object pointer will be obtained from this pool.raw
- the canonical formatted tag to be parsed. This buffer will be retained by the returnedRevTag
and must not be modified by the caller.- Returns:
- the parsed tag, in an isolated revision pool that is not available to the caller.
- Throws:
CorruptObjectException
- the tag contains a malformed header that cannot be handled.
-
parseHeaders
void parseHeaders(RevWalk walk) throws MissingObjectException, IncorrectObjectTypeException, java.io.IOException
- Specified by:
parseHeaders
in classRevObject
- Throws:
MissingObjectException
IncorrectObjectTypeException
java.io.IOException
-
parseBody
void parseBody(RevWalk walk) throws MissingObjectException, IncorrectObjectTypeException, java.io.IOException
- Specified by:
parseBody
in classRevObject
- Throws:
MissingObjectException
IncorrectObjectTypeException
java.io.IOException
-
parseCanonical
void parseCanonical(RevWalk walk, byte[] rawTag) throws CorruptObjectException
- Throws:
CorruptObjectException
-
getType
public final int getType()
Get Git object type. SeeConstants
.
-
getTaggerIdent
public final PersonIdent getTaggerIdent()
Parse the tagger identity from the raw buffer.This method parses and returns the content of the tagger line, after taking the tag's character set into account and decoding the tagger name and email address. This method is fairly expensive and produces a new PersonIdent instance on each invocation. Callers should invoke this method only if they are certain they will be outputting the result, and should cache the return value for as long as necessary to use all information from it.
- Returns:
- identity of the tagger (name, email) and the time the tag was made by the tagger; null if no tagger line was found.
-
getFullMessage
public final java.lang.String getFullMessage()
Parse the complete tag message and decode it to a string.This method parses and returns the message portion of the tag buffer, after taking the tag's character set into account and decoding the buffer using that character set. This method is a fairly expensive operation and produces a new string on each invocation.
- Returns:
- decoded tag message as a string. Never null.
-
getShortMessage
public final java.lang.String getShortMessage()
Parse the tag message and return the first "line" of it.The first line is everything up to the first pair of LFs. This is the "oneline" format, suitable for output in a single line display.
This method parses and returns the message portion of the tag buffer, after taking the tag's character set into account and decoding the buffer using that character set. This method is a fairly expensive operation and produces a new string on each invocation.
- Returns:
- decoded tag message as a string. Never null. The returned string does not contain any LFs, even if the first paragraph spanned multiple lines. Embedded LFs are converted to spaces.
-
guessEncoding
private java.nio.charset.Charset guessEncoding()
-
getObject
public final RevObject getObject()
Get a reference to the object this tag was placed on.Note that the returned object has only been looked up (see
RevWalk.lookupAny(AnyObjectId, int)
. To access the contents it needs to be parsed, seeRevWalk.parseHeaders(RevObject)
andRevWalk.parseBody(RevObject)
.As an alternative, use
RevWalk.peel(RevObject)
and pass thisRevTag
to peel it until the first non-tag object.- Returns:
- object this tag refers to (only looked up, not parsed)
-
getTagName
public final java.lang.String getTagName()
Get the name of this tag, from the tag header.- Returns:
- name of the tag, according to the tag header.
-
disposeBody
public final void disposeBody()
Discard the message buffer to reduce memory usage.After discarding the memory usage of the
RevTag
is reduced to only thegetObject()
pointer andgetTagName()
. Accessing other properties such asgetTaggerIdent()
or either message function requires reloading the buffer by invokingRevWalk.parseBody(RevObject)
.- Since:
- 4.0
-
-