Package org.eclipse.jgit.api
Class TagCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<Ref>
-
- org.eclipse.jgit.api.TagCommand
-
public class TagCommand extends GitCommand<Ref>
Create/update an annotated tag object or a simple unannotated tagExamples (
gitis aGitinstance):Create a new tag for the current commit:
git.tag().setName("v1.0").setMessage("First stable release").call();Create a new unannotated tag for the current commit:
git.tag().setName("v1.0").setAnnotated(false).call();- See Also:
- Git documentation about Tag
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTagCommand(Repository repo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Refcall()Executes thetagcommand with all the options and parameters collected by the setter methods of this class.StringgetMessage()StringgetName()RevObjectgetObjectId()PersonIdentgetTagger()booleanisAnnotated()booleanisForceUpdate()booleanisSigned()TagCommandsetAnnotated(boolean annotated)TagCommandsetForceUpdate(boolean forceUpdate)If set to true the Tag command may replace an existing tag object.TagCommandsetMessage(String message)TagCommandsetName(String name)TagCommandsetObjectId(RevObject id)Sets the object id of the tag.TagCommandsetSigned(boolean signed)If set to true the Tag command creates a signed tag object.TagCommandsetTagger(PersonIdent tagger)Sets the tagger of the tag.-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Constructor Detail
-
TagCommand
protected TagCommand(Repository repo)
- Parameters:
repo-
-
-
Method Detail
-
call
public Ref call() throws GitAPIException, ConcurrentRefUpdateException, InvalidTagNameException, NoHeadException
Executes thetagcommand with all the options and parameters collected by the setter methods of this class. Each instance of this class should only be used for one invocation of the command (means: one call tocall())- Specified by:
callin interfaceCallable<Ref>- Specified by:
callin classGitCommand<Ref>- Returns:
- a
Refa ref pointing to a tag - Throws:
NoHeadException- when called on a git repo without a HEAD referenceGitAPIException- or subclass thereof when an error occursConcurrentRefUpdateExceptionInvalidTagNameException- Since:
- 2.0
-
setName
public TagCommand setName(String name)
- Parameters:
name- the tag name used for thetag- Returns:
this
-
getName
public String getName()
- Returns:
- the tag name used for the
tag
-
getMessage
public String getMessage()
- Returns:
- the tag message used for the
tag
-
setMessage
public TagCommand setMessage(String message)
- Parameters:
message- the tag message used for thetag- Returns:
this
-
isSigned
public boolean isSigned()
- Returns:
- whether the tag is signed
-
setSigned
public TagCommand setSigned(boolean signed)
If set to true the Tag command creates a signed tag object. This corresponds to the parameter -s on the command line.- Parameters:
signed-- Returns:
this
-
setTagger
public TagCommand setTagger(PersonIdent tagger)
Sets the tagger of the tag. If the tagger is null, a PersonIdent will be created from the info in the repository.- Parameters:
tagger-- Returns:
this
-
getTagger
public PersonIdent getTagger()
- Returns:
- the tagger of the tag
-
getObjectId
public RevObject getObjectId()
- Returns:
- the object id of the tag
-
setObjectId
public TagCommand setObjectId(RevObject id)
Sets the object id of the tag. If the object id is null, the commit pointed to from HEAD will be used.- Parameters:
id-- Returns:
this
-
isForceUpdate
public boolean isForceUpdate()
- Returns:
- is this a force update
-
setForceUpdate
public TagCommand setForceUpdate(boolean forceUpdate)
If set to true the Tag command may replace an existing tag object. This corresponds to the parameter -f on the command line.- Parameters:
forceUpdate-- Returns:
this
-
setAnnotated
public TagCommand setAnnotated(boolean annotated)
- Parameters:
annotated-- Returns:
this- Since:
- 3.0
-
isAnnotated
public boolean isAnnotated()
- Returns:
- true if this command will create an annotated tag (default is true)
- Since:
- 3.0
-
-