@@ -50,6 +50,9 @@ type CloneOptions struct {
50
50
// stored, if nil nothing is stored and the capability (if supported)
51
51
// no-progress, is sent to the server to avoid send this information.
52
52
Progress sideband.Progress
53
+ // Tags describe how the tags will be fetched from the remote repository,
54
+ // by default is AllTags.
55
+ Tags TagMode
53
56
}
54
57
55
58
// Validate validates the fields and sets the default values.
@@ -66,6 +69,10 @@ func (o *CloneOptions) Validate() error {
66
69
o .ReferenceName = plumbing .HEAD
67
70
}
68
71
72
+ if o .Tags == InvalidTagMode {
73
+ o .Tags = AllTags
74
+ }
75
+
69
76
return nil
70
77
}
71
78
@@ -103,18 +110,19 @@ func (o *PullOptions) Validate() error {
103
110
return nil
104
111
}
105
112
106
- type TagFetchMode int
113
+ type TagMode int
107
114
108
- var (
115
+ const (
116
+ InvalidTagMode TagMode = iota
109
117
// TagFollowing any tag that points into the histories being fetched is also
110
118
// fetched. TagFollowing requires a server with `include-tag` capability
111
119
// in order to fetch the annotated tags objects.
112
- TagFollowing TagFetchMode = 0
120
+ TagFollowing
113
121
// AllTags fetch all tags from the remote (i.e., fetch remote tags
114
122
// refs/tags/* into local tags with the same name)
115
- AllTags TagFetchMode = 1
123
+ AllTags
116
124
//NoTags fetch no tags from the remote at all
117
- NoTags TagFetchMode = 2
125
+ NoTags
118
126
)
119
127
120
128
// FetchOptions describes how a fetch should be performed
@@ -133,7 +141,7 @@ type FetchOptions struct {
133
141
Progress sideband.Progress
134
142
// Tags describe how the tags will be fetched from the remote repository,
135
143
// by default is TagFollowing.
136
- Tags TagFetchMode
144
+ Tags TagMode
137
145
}
138
146
139
147
// Validate validates the fields and sets the default values.
@@ -142,6 +150,10 @@ func (o *FetchOptions) Validate() error {
142
150
o .RemoteName = DefaultRemoteName
143
151
}
144
152
153
+ if o .Tags == InvalidTagMode {
154
+ o .Tags = TagFollowing
155
+ }
156
+
145
157
for _ , r := range o .RefSpecs {
146
158
if err := r .Validate (); err != nil {
147
159
return err
0 commit comments