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 (
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 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()
String
getMessage()
Get the tagmessage
.String
getName()
Get the tagname
.RevObject
getObjectId()
Get the tag's object idString
getSigningKey()
Retrieves the signing key ID.PersonIdent
getTagger()
Get thetagger
who created the tag.boolean
isAnnotated()
Whether this will create an annotated tag.boolean
isForceUpdate()
Whether this is a forced updateboolean
isSigned()
WhethersetSigned(true)
has been called or whether asigning key ID
has been set; i.e., whether -s or -u was specified explicitly.TagCommand
setAnnotated(boolean annotated)
Configure this tag to be created as an annotated tagTagCommand
setCredentialsProvider(CredentialsProvider credentialsProvider)
Sets aCredentialsProvider
TagCommand
setForceUpdate(boolean forceUpdate)
If set to true the Tag command may replace an existing tag object.TagCommand
setGpgConfig(GpgConfig config)
Sets an externalGpgConfig
to use.TagCommand
setGpgSigner(GpgObjectSigner signer)
Sets theGpgSigner
to use if the commit is to be signed.TagCommand
setMessage(String message)
Set the tagmessage
.TagCommand
setName(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
setSigningKey(String signingKey)
Sets the signing key.TagCommand
setTagger(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)
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 interfaceCallable<Ref>
- Specified by:
call
in classGitCommand<Ref>
- Throws:
GitAPIException
ConcurrentRefUpdateException
InvalidTagNameException
NoHeadException
- Since:
- 2.0
-
setName
public TagCommand setName(String name)
Set the tagname
.- Parameters:
name
- the tag name used for thetag
- Returns:
this
-
getName
public String getName()
Get the tagname
.- Returns:
- the tag name used for the
tag
-
getMessage
public String getMessage()
Get the tagmessage
.- Returns:
- the tag message used for the
tag
-
setMessage
public TagCommand setMessage(String message)
Set the tagmessage
.- Parameters:
message
- the tag message used for thetag
- Returns:
this
-
isSigned
public boolean isSigned()
WhethersetSigned(true)
has been called or whether asigning key ID
has been set; i.e., whether -s or -u was specified explicitly.- 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 (--sign or --no-sign) on the command line.If
true
, the tag will be a signed annotated tag.- Parameters:
signed
- whether to sign- Returns:
this
-
setGpgSigner
public TagCommand setGpgSigner(GpgObjectSigner signer)
Sets theGpgSigner
to use if the commit is to be signed.- Parameters:
signer
- to use; ifnull
, the default signer will be used- Returns:
this
- Since:
- 5.11
-
setGpgConfig
public TagCommand setGpgConfig(GpgConfig config)
Sets an externalGpgConfig
to use. Whether it will be used is at the discretion of thesetGpgSigner(GpgObjectSigner)
.- Parameters:
config
- to set; ifnull
, the config will be loaded from the git config of the repository- Returns:
this
- Since:
- 5.11
-
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 isnull
, 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 tag.- Returns:
- true if this command will create an annotated tag (default is true)
- Since:
- 3.0
-
setSigningKey
public TagCommand setSigningKey(String signingKey)
Sets the signing key.Per spec of
user.signingKey
: this will be sent to the GPG program as is, i.e. can be anything supported by the GPG program.Note, if none was set or
null
is specified a default will be obtained from the configuration.If set to a non-
null
value, the tag will be a signed annotated tag.- Parameters:
signingKey
- signing key;null
allowed- Returns:
this
- Since:
- 5.11
-
getSigningKey
public String getSigningKey()
Retrieves the signing key ID.- Returns:
- the key ID set, or
null
if none is set - Since:
- 5.11
-
setCredentialsProvider
public TagCommand setCredentialsProvider(CredentialsProvider credentialsProvider)
Sets aCredentialsProvider
- Parameters:
credentialsProvider
- the provider to use when querying for credentials (eg., during signing)- Returns:
this
- Since:
- 5.11
-
-