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 Booleanprivate CredentialsProviderprivate booleanprivate GpgConfigprivate GpgObjectSignerprivate RevObjectprivate Stringprivate Stringprivate Booleanprivate Stringprivate PersonIdentFields 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 thetaggerwho created the tag.booleanWhether this will create an annotated tag.booleanWhether this is a forced updatebooleanisSigned()WhethersetSigned(true)has been called or whether asigning key IDhas been set; i.e., whether -s or -u was specified explicitly.private voidprocessOptions(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 aCredentialsProvidersetForceUpdate(boolean forceUpdate) If set to true the Tag command may replace an existing tag object.setGpgConfig(GpgConfig config) Sets an externalGpgConfigto use.setGpgSigner(GpgObjectSigner signer) Sets theGpgSignerto 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 RefupdateTagRef(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- aRepositoryobject.
-
-
Method Details
-
call
public Ref call() throws GitAPIException, ConcurrentRefUpdateException, InvalidTagNameException, NoHeadExceptionExecute the command
Executes the
tagcommand 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>- Throws:
GitAPIExceptionConcurrentRefUpdateExceptionInvalidTagNameExceptionNoHeadException- 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.formatis 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 IDhas 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 theGpgSignerto 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 externalGpgConfigto 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- aPersonIdentobject.- Returns:
this
-
getTagger
Get thetaggerwho 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- aRevObjectobject.- 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
nullis specified a default will be obtained from the configuration.If set to a non-
nullvalue, the tag will be a signed annotated tag.- Parameters:
signingKey- signing key;nullallowed- Returns:
this- Since:
- 5.11
-
getSigningKey
Retrieves the signing key ID.- Returns:
- the key ID set, or
nullif 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
-