Class TagCommand
Examples (git
is a Git
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Boolean
private CredentialsProvider
private boolean
private GpgConfig
private GpgObjectSigner
private RevObject
private String
private String
private Boolean
private String
private PersonIdent
Fields inherited from class org.eclipse.jgit.api.GitCommand
repo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall()
Get the tagmessage
.getName()
Get the tagname
.Get the tag's object idRetrieves the signing key ID.Get thetagger
who created the tag.boolean
Whether this will create an annotated tag.boolean
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.private void
processOptions
(RepositoryState state) Sets default values for not explicitly specified options.setAnnotated
(boolean annotated) Configure this tag to be created as an annotated tagsetCredentialsProvider
(CredentialsProvider credentialsProvider) Sets aCredentialsProvider
setForceUpdate
(boolean forceUpdate) If set to true the Tag command may replace an existing tag object.setGpgConfig
(GpgConfig config) Sets an externalGpgConfig
to use.setGpgSigner
(GpgObjectSigner signer) Sets theGpgSigner
to use if the commit is to be signed.setMessage
(String message) Set the tagmessage
.Set the tagname
.setObjectId
(RevObject id) Sets the object id of the tag.setSigned
(boolean signed) If set to true the Tag command creates a signed tag object.setSigningKey
(String signingKey) Sets the signing key.setTagger
(PersonIdent tagger) Sets the tagger of the tag.private Ref
updateTagRef
(ObjectId tagId, RevWalk revWalk, String tagName, String newTagToString) Methods inherited from class org.eclipse.jgit.api.GitCommand
checkCallable, getRepository, setCallable
-
Field Details
-
id
-
name
-
message
-
tagger
-
signed
-
forceUpdate
private boolean forceUpdate -
annotated
-
signingKey
-
gpgConfig
-
gpgSigner
-
credentialsProvider
-
-
Constructor Details
-
TagCommand
Constructor for TagCommand.
- Parameters:
repo
- aRepository
object.
-
-
Method Details
-
call
public Ref call() throws GitAPIException, ConcurrentRefUpdateException, InvalidTagNameException, NoHeadExceptionExecute 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
-
updateTagRef
private Ref updateTagRef(ObjectId tagId, RevWalk revWalk, String tagName, String newTagToString) throws IOException, ConcurrentRefUpdateException, RefAlreadyExistsException -
processOptions
private void processOptions(RepositoryState state) throws InvalidTagNameException, ServiceUnavailableException, UnsupportedSigningFormatException 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 invalidServiceUnavailableException
- if the tag should be signed but no signer can be foundUnsupportedSigningFormatException
- if the tag should be signed butgpg.format
is notGpgConfig.GpgFormat.OPENPGP
-
setName
Set the tagname
.- Parameters:
name
- the tag name used for thetag
- Returns:
this
-
getName
Get the tagname
.- Returns:
- the tag name used for the
tag
-
getMessage
Get the tagmessage
.- Returns:
- the tag message used for the
tag
-
setMessage
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
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
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
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
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
Get thetagger
who created the tag.- Returns:
- the tagger of the tag
-
getObjectId
Get the tag's object id- Returns:
- the object id of the tag
-
setObjectId
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
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
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
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
Retrieves the signing key ID.- Returns:
- the key ID set, or
null
if none is set - Since:
- 5.11
-
setCredentialsProvider
Sets aCredentialsProvider
- Parameters:
credentialsProvider
- the provider to use when querying for credentials (eg., during signing)- Returns:
this
- Since:
- 5.11
-