@@ -50,6 +50,9 @@ type CloneOptions struct {
5050 // stored, if nil nothing is stored and the capability (if supported)
5151 // no-progress, is sent to the server to avoid send this information.
5252 Progress sideband.Progress
53+ // Tags describe how the tags will be fetched from the remote repository,
54+ // by default is AllTags.
55+ Tags TagMode
5356}
5457
5558// Validate validates the fields and sets the default values.
@@ -66,6 +69,10 @@ func (o *CloneOptions) Validate() error {
6669 o .ReferenceName = plumbing .HEAD
6770 }
6871
72+ if o .Tags == InvalidTagMode {
73+ o .Tags = AllTags
74+ }
75+
6976 return nil
7077}
7178
@@ -103,18 +110,19 @@ func (o *PullOptions) Validate() error {
103110 return nil
104111}
105112
106- type TagFetchMode int
113+ type TagMode int
107114
108- var (
115+ const (
116+ InvalidTagMode TagMode = iota
109117 // TagFollowing any tag that points into the histories being fetched is also
110118 // fetched. TagFollowing requires a server with `include-tag` capability
111119 // in order to fetch the annotated tags objects.
112- TagFollowing TagFetchMode = 0
120+ TagFollowing
113121 // AllTags fetch all tags from the remote (i.e., fetch remote tags
114122 // refs/tags/* into local tags with the same name)
115- AllTags TagFetchMode = 1
123+ AllTags
116124 //NoTags fetch no tags from the remote at all
117- NoTags TagFetchMode = 2
125+ NoTags
118126)
119127
120128// FetchOptions describes how a fetch should be performed
@@ -133,7 +141,7 @@ type FetchOptions struct {
133141 Progress sideband.Progress
134142 // Tags describe how the tags will be fetched from the remote repository,
135143 // by default is TagFollowing.
136- Tags TagFetchMode
144+ Tags TagMode
137145}
138146
139147// Validate validates the fields and sets the default values.
@@ -142,6 +150,10 @@ func (o *FetchOptions) Validate() error {
142150 o .RemoteName = DefaultRemoteName
143151 }
144152
153+ if o .Tags == InvalidTagMode {
154+ o .Tags = TagFollowing
155+ }
156+
145157 for _ , r := range o .RefSpecs {
146158 if err := r .Validate (); err != nil {
147159 return err
0 commit comments