writeTag
Write an annotated tag object directly
param | type [= default] | description |
---|---|---|
fs | FsClient | a file system client |
dir | string | The working tree directory path |
gitdir | string = join(dir,'.git') | The git directory path |
tag | TagObject | The object to write |
return | Promise<string> | Resolves successfully with the SHA-1 object id of the newly written object |
A git annotated tag object.
type TagObject = {
object: string; // SHA-1 object id of object being tagged
type: 'blob' | 'tree' | 'commit' | 'tag'; // the type of the object being tagged
tag: string; // the tag name
tagger: {
name: string; // the tagger's name
email: string; // the tagger's email
timestamp: number; // UTC Unix timestamp in seconds
timezoneOffset: number; // timezone difference from UTC in minutes
};
message: string; // tag message
gpgsig?: string; // PGP signature (if present)
}
Example Code:
// Manually create an annotated tag.let sha = await git.resolveRef({ fs, dir: '/tutorial', ref: 'HEAD' })console.log('commit', sha)let oid = await git.writeTag({fs,dir: '/tutorial',tag: {object: sha,type: 'commit',tag: 'my-tag',tagger: {name: 'your name',email: 'email@example.com',timestamp: Math.floor(Date.now()/1000),timezoneOffset: new Date().getTimezoneOffset()},message: 'Optional message'}})console.log('tag', oid)