@@ -17,24 +17,24 @@ import (
1717const TagPrefix = "refs/tags/"
1818
1919// CreateTag create one tag in the repository
20- func (repo * Repository ) CreateTag (name , revision string ) error {
21- _ , _ , err := NewCommand ("tag" ).AddDashesAndList (name , revision ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
20+ func (repo * Repository ) CreateTag (ctx context. Context , name , revision string ) error {
21+ _ , _ , err := NewCommand ("tag" ).AddDashesAndList (name , revision ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
2222 return err
2323}
2424
2525// CreateAnnotatedTag create one annotated tag in the repository
26- func (repo * Repository ) CreateAnnotatedTag (name , message , revision string ) error {
27- _ , _ , err := NewCommand ("tag" , "-a" , "-m" ).AddDynamicArguments (message ).AddDashesAndList (name , revision ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
26+ func (repo * Repository ) CreateAnnotatedTag (ctx context. Context , name , message , revision string ) error {
27+ _ , _ , err := NewCommand ("tag" , "-a" , "-m" ).AddDynamicArguments (message ).AddDashesAndList (name , revision ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
2828 return err
2929}
3030
3131// GetTagNameBySHA returns the name of a tag from its tag object SHA or commit SHA
32- func (repo * Repository ) GetTagNameBySHA (sha string ) (string , error ) {
32+ func (repo * Repository ) GetTagNameBySHA (ctx context. Context , sha string ) (string , error ) {
3333 if len (sha ) < 5 {
3434 return "" , fmt .Errorf ("SHA is too short: %s" , sha )
3535 }
3636
37- stdout , _ , err := NewCommand ("show-ref" , "--tags" , "-d" ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
37+ stdout , _ , err := NewCommand ("show-ref" , "--tags" , "-d" ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
3838 if err != nil {
3939 return "" , err
4040 }
@@ -56,8 +56,8 @@ func (repo *Repository) GetTagNameBySHA(sha string) (string, error) {
5656}
5757
5858// GetTagID returns the object ID for a tag (annotated tags have both an object SHA AND a commit SHA)
59- func (repo * Repository ) GetTagID (name string ) (string , error ) {
60- stdout , _ , err := NewCommand ("show-ref" , "--tags" ).AddDashesAndList (name ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
59+ func (repo * Repository ) GetTagID (ctx context. Context , name string ) (string , error ) {
60+ stdout , _ , err := NewCommand ("show-ref" , "--tags" ).AddDashesAndList (name ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
6161 if err != nil {
6262 return "" , err
6363 }
@@ -72,8 +72,8 @@ func (repo *Repository) GetTagID(name string) (string, error) {
7272}
7373
7474// GetTag returns a Git tag by given name.
75- func (repo * Repository ) GetTag (name string ) (* Tag , error ) {
76- idStr , err := repo .GetTagID (name )
75+ func (repo * Repository ) GetTag (ctx context. Context , name string ) (* Tag , error ) {
76+ idStr , err := repo .GetTagID (ctx , name )
7777 if err != nil {
7878 return nil , err
7979 }
@@ -105,7 +105,7 @@ func (repo *Repository) GetTagWithID(idStr, name string) (*Tag, error) {
105105}
106106
107107// GetTagInfos returns all tag infos of the repository.
108- func (repo * Repository ) GetTagInfos (page , pageSize int ) ([]* Tag , int , error ) {
108+ func (repo * Repository ) GetTagInfos (ctx context. Context , page , pageSize int ) ([]* Tag , int , error ) {
109109 // Generally, refname:short should be equal to refname:lstrip=2 except core.warnAmbiguousRefs is used to select the strict abbreviation mode.
110110 // https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-refname
111111 forEachRefFmt := foreachref .NewFormat ("objecttype" , "refname:lstrip=2" , "object" , "objectname" , "creator" , "contents" , "contents:signature" )
@@ -119,7 +119,7 @@ func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, int, error) {
119119 go func () {
120120 err := NewCommand ("for-each-ref" ).
121121 AddOptionFormat ("--format=%s" , forEachRefFmt .Flag ()).
122- AddArguments ("--sort" , "-*creatordate" , "refs/tags" ).Run (repo . Ctx , rc )
122+ AddArguments ("--sort" , "-*creatordate" , "refs/tags" ).Run (ctx , rc )
123123 if err != nil {
124124 _ = stdoutWriter .CloseWithError (ConcatenateError (err , stderr .String ()))
125125 } else {
@@ -197,7 +197,7 @@ func parseTagRef(ref map[string]string) (tag *Tag, err error) {
197197}
198198
199199// GetAnnotatedTag returns a Git tag by its SHA, must be an annotated tag
200- func (repo * Repository ) GetAnnotatedTag (sha string ) (* Tag , error ) {
200+ func (repo * Repository ) GetAnnotatedTag (ctx context. Context , sha string ) (* Tag , error ) {
201201 id , err := NewIDFromString (sha )
202202 if err != nil {
203203 return nil , err
@@ -212,7 +212,7 @@ func (repo *Repository) GetAnnotatedTag(sha string) (*Tag, error) {
212212 }
213213
214214 // Get tag name
215- name , err := repo .GetTagNameBySHA (id .String ())
215+ name , err := repo .GetTagNameBySHA (ctx , id .String ())
216216 if err != nil {
217217 return nil , err
218218 }
0 commit comments