@@ -17,24 +17,24 @@ import (
17
17
const TagPrefix = "refs/tags/"
18
18
19
19
// 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 })
22
22
return err
23
23
}
24
24
25
25
// 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 })
28
28
return err
29
29
}
30
30
31
31
// 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 ) {
33
33
if len (sha ) < 5 {
34
34
return "" , fmt .Errorf ("SHA is too short: %s" , sha )
35
35
}
36
36
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 })
38
38
if err != nil {
39
39
return "" , err
40
40
}
@@ -56,8 +56,8 @@ func (repo *Repository) GetTagNameBySHA(sha string) (string, error) {
56
56
}
57
57
58
58
// 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 })
61
61
if err != nil {
62
62
return "" , err
63
63
}
@@ -72,8 +72,8 @@ func (repo *Repository) GetTagID(name string) (string, error) {
72
72
}
73
73
74
74
// 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 )
77
77
if err != nil {
78
78
return nil , err
79
79
}
@@ -105,7 +105,7 @@ func (repo *Repository) GetTagWithID(idStr, name string) (*Tag, error) {
105
105
}
106
106
107
107
// 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 ) {
109
109
// Generally, refname:short should be equal to refname:lstrip=2 except core.warnAmbiguousRefs is used to select the strict abbreviation mode.
110
110
// https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-refname
111
111
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) {
119
119
go func () {
120
120
err := NewCommand ("for-each-ref" ).
121
121
AddOptionFormat ("--format=%s" , forEachRefFmt .Flag ()).
122
- AddArguments ("--sort" , "-*creatordate" , "refs/tags" ).Run (repo . Ctx , rc )
122
+ AddArguments ("--sort" , "-*creatordate" , "refs/tags" ).Run (ctx , rc )
123
123
if err != nil {
124
124
_ = stdoutWriter .CloseWithError (ConcatenateError (err , stderr .String ()))
125
125
} else {
@@ -197,7 +197,7 @@ func parseTagRef(ref map[string]string) (tag *Tag, err error) {
197
197
}
198
198
199
199
// 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 ) {
201
201
id , err := NewIDFromString (sha )
202
202
if err != nil {
203
203
return nil , err
@@ -212,7 +212,7 @@ func (repo *Repository) GetAnnotatedTag(sha string) (*Tag, error) {
212
212
}
213
213
214
214
// Get tag name
215
- name , err := repo .GetTagNameBySHA (id .String ())
215
+ name , err := repo .GetTagNameBySHA (ctx , id .String ())
216
216
if err != nil {
217
217
return nil , err
218
218
}
0 commit comments