Package org.eclipse.jgit.api
Class TagCommand
- java.lang.Object
-
- org.eclipse.jgit.api.GitCommand<Ref>
-
- org.eclipse.jgit.api.TagCommand
-
- All Implemented Interfaces:
java.util.concurrent.Callable<Ref>
public class TagCommand extends GitCommand<Ref>
Create/update an annotated tag object or a simple unannotated tagExamples (
git
is aGit
instance):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 Modifier and Type Field Description private boolean
annotated
private boolean
forceUpdate
private RevObject
id
private java.lang.String
message
private java.lang.String
name
private boolean
signed
private PersonIdent
tagger
-
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TagCommand(Repository repo)
Constructor for TagCommand.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Ref
call()
java.lang.String
getMessage()
Get the tagmessage
.java.lang.String
getName()
Get the tagname
.RevObject
getObjectId()
Get the tag's object idPersonIdent
getTagger()
Get thetagger
who created the tag.boolean
isAnnotated()
Whether this will create an annotated commandboolean
isForceUpdate()
Whether this is a forced updateboolean
isSigned()
Whether this tag is signedprivate void
processOptions(RepositoryState state)
Sets default values for not explicitly specified options.TagCommand
setAnnotated(boolean annotated)
Configure this tag to be created as an annotated tagTagCommand
setForceUpdate(boolean forceUpdate)
If set to true the Tag command may replace an existing tag object.TagCommand
setMessage(java.lang.String message)
Set the tagmessage
.TagCommand
setName(java.lang.String name)
Set the tagname
.TagCommand
setObjectId(RevObject id)
Sets the object id of the tag.TagCommand
setSigned(boolean signed)
If set to true the Tag command creates a signed tag object.TagCommand
setTagger(PersonIdent tagger)
Sets the tagger of the tag.private Ref
updateTagRef(ObjectId tagId, RevWalk revWalk, java.lang.String tagName, java.lang.String newTagToString)
-
Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
-
-
-
Field Detail
-
id
private RevObject id
-
name
private java.lang.String name
-
message
private java.lang.String message
-
tagger
private PersonIdent tagger
-
signed
private boolean signed
-
forceUpdate
private boolean forceUpdate
-
annotated
private boolean annotated
-
-
Constructor Detail
-
TagCommand
protected TagCommand(Repository repo)
Constructor for TagCommand.
- Parameters:
repo
- aRepository
object.
-
-
Method Detail
-
call
public Ref call() throws GitAPIException, ConcurrentRefUpdateException, InvalidTagNameException, NoHeadException
Execute the command
Executes the
tag
command 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:
call
in interfacejava.util.concurrent.Callable<Ref>
- Specified by:
call
in classGitCommand<Ref>
- Throws:
GitAPIException
ConcurrentRefUpdateException
InvalidTagNameException
NoHeadException
- Since:
- 2.0
-
updateTagRef
private Ref updateTagRef(ObjectId tagId, RevWalk revWalk, java.lang.String tagName, java.lang.String newTagToString) throws java.io.IOException, ConcurrentRefUpdateException, RefAlreadyExistsException
- Throws:
java.io.IOException
ConcurrentRefUpdateException
RefAlreadyExistsException
-
processOptions
private void processOptions(RepositoryState state) throws InvalidTagNameException
Sets default values for not explicitly specified options. Then validates that all required data has been provided.- Parameters:
state
- the state of the repository we are working on- Throws:
InvalidTagNameException
- if the tag name is null or invalidjava.lang.UnsupportedOperationException
- if the tag is signed (not supported yet)
-
setName
public TagCommand setName(java.lang.String name)
Set the tagname
.- Parameters:
name
- the tag name used for thetag
- Returns:
this
-
getName
public java.lang.String getName()
Get the tagname
.- Returns:
- the tag name used for the
tag
-
getMessage
public java.lang.String getMessage()
Get the tagmessage
.- Returns:
- the tag message used for the
tag
-
setMessage
public TagCommand setMessage(java.lang.String message)
Set the tagmessage
.- Parameters:
message
- the tag message used for thetag
- Returns:
this
-
isSigned
public boolean isSigned()
Whether this tag is signed- 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
- a boolean.- 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
- aPersonIdent
object.- Returns:
this
-
getTagger
public PersonIdent getTagger()
Get thetagger
who created the tag.- Returns:
- the tagger of the tag
-
getObjectId
public RevObject getObjectId()
Get the tag's object id- 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
- aRevObject
object.- Returns:
this
-
isForceUpdate
public boolean isForceUpdate()
Whether this is a forced update- 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
- whether this is a forced update- Returns:
this
-
setAnnotated
public TagCommand setAnnotated(boolean annotated)
Configure this tag to be created as an annotated tag- Parameters:
annotated
- whether this shall be an annotated tag- Returns:
this
- Since:
- 3.0
-
isAnnotated
public boolean isAnnotated()
Whether this will create an annotated command- Returns:
- true if this command will create an annotated tag (default is true)
- Since:
- 3.0
-
-