createTag
Create a new tag in the repository from an object.
A new reference will also be created pointing to this tag object.
The message will not be cleaned up.
The tag name will be checked for validity. You must avoid the characters '~', '^', ':', ' \ ', '?', '[', and '*', and the sequences ".." and " @ {" which have special meaning to revparse.
Signature
class Repository {
createTag(
name: string,
target: GitObject,
message: string,
options?: CreateTagOptions,
): string;
}
Parameters
- namerequired · string
The name of tag.
- targetrequired · GitObject
Git object to pointed by this tag.
- messagerequired · string
The message of tag.
- optionsnull | CreateTagOptions
Options for creating the tag.
- forceboolean
If
force
is true and a reference already exists with the given name, it'll be replaced. - taggerSignaturePayload
Signature for tagger. If not provided, default signature of repository will be used. If there is no default signature set for the repository, an error will occur.
- emailrequired · string
Email on the signature.
- namerequired · string
Name on the signature.
- timeOptionsSignatureTimeOptions
- offsetnumber
Timezone offset, in minutes
- timestamprequired · number
Time in seconds, from epoch
- offsetnumber
- emailrequired · string
- forceboolean
Returns
- string
Tag OID(SHA1) which created.
Examples
import { openRepository } from 'es-git';
const repo = await openRepository('.');
const commit = repo.getCommit('828954df9f08dc8e172447cdacf0ddea1adf9e63');
const sha = repo.createTag(
'mytag',
commit.asObject(),
'this is my tag message',
{
tagger: {
name: 'Seokju Na',
email: 'seokju.me@toss.im',
},
},
);
const tag = repo.getTag(sha);
console.log(tag.name()); // "mytag"
console.log(tag.target().id()); // "828954df9f08dc8e172447cdacf0ddea1adf9e63"