MCPcopy Create free account
hub / github.com/docker/secrets-engine / GetNextVersion

Method GetNextVersion

x/release/helper/release.go:207–236  ·  view source on GitHub ↗
(level Level)

Source from the content-addressed store, hash-verified

205}
206
207func (s *Version) GetNextVersion(level Level) (string, error) {
208 v, extra := CutVersionExtra(s.Current)
209 v = semver.Canonical(v)
210 if v == "" {
211 return "", fmt.Errorf("not a canonical version: %s", s.Current)
212 }
213 parts := strings.SplitN(strings.TrimPrefix(v, "v"), ".", 3)
214 if len(parts) != 3 {
215 return "", fmt.Errorf("unexpected semver parts: %q", v)
216 }
217 major, err1 := strconv.Atoi(parts[0])
218 minor, err2 := strconv.Atoi(parts[1])
219 patch, err3 := strconv.Atoi(parts[2])
220 if err1 != nil || err2 != nil || err3 != nil {
221 return "", fmt.Errorf("failed to parse semver numbers %q: %s", v, errors.Join(err1, err2, err3))
222 }
223 var next string
224 switch level {
225 case Major:
226 next = fmt.Sprintf("v%d.0.0", major+1)
227 case Minor:
228 next = fmt.Sprintf("v%d.%d.0", major, minor+1)
229 default:
230 next = fmt.Sprintf("v%d.%d.%d", major, minor, patch+1)
231 }
232 if !s.KeepExtra {
233 extra = ""
234 }
235 return next + extra, nil
236}
237
238func CutVersionExtra(cv string) (string, string) {
239 if i := strings.IndexByte(cv, '-'); i >= 0 {

Callers 2

Test_futureVersionFunction · 0.95
BumpModuleFunction · 0.80

Calls 2

CutVersionExtraFunction · 0.85
ErrorfMethod · 0.65

Tested by 1

Test_futureVersionFunction · 0.76