@@ -23,24 +23,24 @@ func IsTagExist(ctx context.Context, repoPath, name string) bool {
2323}
2424
2525// CreateTag create one tag in the repository
26- func (repo * Repository ) CreateTag (name , revision string ) error {
27- _ , _ , err := NewCommand ("tag" ).AddDashesAndList (name , revision ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
26+ func (repo * Repository ) CreateTag (ctx context. Context , name , revision string ) error {
27+ _ , _ , err := NewCommand ("tag" ).AddDashesAndList (name , revision ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
2828 return err
2929}
3030
3131// CreateAnnotatedTag create one annotated tag in the repository
32- func (repo * Repository ) CreateAnnotatedTag (name , message , revision string ) error {
33- _ , _ , err := NewCommand ("tag" , "-a" , "-m" ).AddDynamicArguments (message ).AddDashesAndList (name , revision ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
32+ func (repo * Repository ) CreateAnnotatedTag (ctx context. Context , name , message , revision string ) error {
33+ _ , _ , err := NewCommand ("tag" , "-a" , "-m" ).AddDynamicArguments (message ).AddDashesAndList (name , revision ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
3434 return err
3535}
3636
3737// GetTagNameBySHA returns the name of a tag from its tag object SHA or commit SHA
38- func (repo * Repository ) GetTagNameBySHA (sha string ) (string , error ) {
38+ func (repo * Repository ) GetTagNameBySHA (ctx context. Context , sha string ) (string , error ) {
3939 if len (sha ) < 5 {
4040 return "" , fmt .Errorf ("SHA is too short: %s" , sha )
4141 }
4242
43- stdout , _ , err := NewCommand ("show-ref" , "--tags" , "-d" ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
43+ stdout , _ , err := NewCommand ("show-ref" , "--tags" , "-d" ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
4444 if err != nil {
4545 return "" , err
4646 }
@@ -62,8 +62,8 @@ func (repo *Repository) GetTagNameBySHA(sha string) (string, error) {
6262}
6363
6464// GetTagID returns the object ID for a tag (annotated tags have both an object SHA AND a commit SHA)
65- func (repo * Repository ) GetTagID (name string ) (string , error ) {
66- stdout , _ , err := NewCommand ("show-ref" , "--tags" ).AddDashesAndList (name ).RunStdString (repo . Ctx , & RunOpts {Dir : repo .Path })
65+ func (repo * Repository ) GetTagID (ctx context. Context , name string ) (string , error ) {
66+ stdout , _ , err := NewCommand ("show-ref" , "--tags" ).AddDashesAndList (name ).RunStdString (ctx , & RunOpts {Dir : repo .Path })
6767 if err != nil {
6868 return "" , err
6969 }
@@ -78,8 +78,8 @@ func (repo *Repository) GetTagID(name string) (string, error) {
7878}
7979
8080// GetTag returns a Git tag by given name.
81- func (repo * Repository ) GetTag (name string ) (* Tag , error ) {
82- idStr , err := repo .GetTagID (name )
81+ func (repo * Repository ) GetTag (ctx context. Context , name string ) (* Tag , error ) {
82+ idStr , err := repo .GetTagID (ctx , name )
8383 if err != nil {
8484 return nil , err
8585 }
@@ -111,7 +111,7 @@ func (repo *Repository) GetTagWithID(idStr, name string) (*Tag, error) {
111111}
112112
113113// GetTagInfos returns all tag infos of the repository.
114- func (repo * Repository ) GetTagInfos (page , pageSize int ) ([]* Tag , int , error ) {
114+ func (repo * Repository ) GetTagInfos (ctx context. Context , page , pageSize int ) ([]* Tag , int , error ) {
115115 // Generally, refname:short should be equal to refname:lstrip=2 except core.warnAmbiguousRefs is used to select the strict abbreviation mode.
116116 // https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-refname
117117 forEachRefFmt := foreachref .NewFormat ("objecttype" , "refname:lstrip=2" , "object" , "objectname" , "creator" , "contents" , "contents:signature" )
@@ -125,7 +125,7 @@ func (repo *Repository) GetTagInfos(page, pageSize int) ([]*Tag, int, error) {
125125 go func () {
126126 err := NewCommand ("for-each-ref" ).
127127 AddOptionFormat ("--format=%s" , forEachRefFmt .Flag ()).
128- AddArguments ("--sort" , "-*creatordate" , "refs/tags" ).Run (repo . Ctx , rc )
128+ AddArguments ("--sort" , "-*creatordate" , "refs/tags" ).Run (ctx , rc )
129129 if err != nil {
130130 _ = stdoutWriter .CloseWithError (ConcatenateError (err , stderr .String ()))
131131 } else {
@@ -203,7 +203,7 @@ func parseTagRef(ref map[string]string) (tag *Tag, err error) {
203203}
204204
205205// GetAnnotatedTag returns a Git tag by its SHA, must be an annotated tag
206- func (repo * Repository ) GetAnnotatedTag (sha string ) (* Tag , error ) {
206+ func (repo * Repository ) GetAnnotatedTag (ctx context. Context , sha string ) (* Tag , error ) {
207207 id , err := NewIDFromString (sha )
208208 if err != nil {
209209 return nil , err
@@ -218,7 +218,7 @@ func (repo *Repository) GetAnnotatedTag(sha string) (*Tag, error) {
218218 }
219219
220220 // Get tag name
221- name , err := repo .GetTagNameBySHA (id .String ())
221+ name , err := repo .GetTagNameBySHA (ctx , id .String ())
222222 if err != nil {
223223 return nil , err
224224 }
0 commit comments