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

Function getLatestVersion

x/release/command.go:246–267  ·  view source on GitHub ↗
(modName string)

Source from the content-addressed store, hash-verified

244}
245
246func getLatestVersion(modName string) (string, error) {
247 cmd := exec.Command("git", "tag", "-l", modName+"/v*", "--sort=-v:refname")
248 out, err := cmd.CombinedOutput()
249 if err != nil {
250 return "", err
251 }
252 lines := strings.Split(string(out), "\n")
253 if len(lines) == 0 {
254 return "", fmt.Errorf("no releases")
255 }
256 latest := strings.TrimSpace(lines[0])
257 prefix := modName + "/"
258
259 if latest == "" {
260 latest = prefix + "v0.0.0"
261 }
262
263 if !strings.HasPrefix(latest, prefix) {
264 return "", fmt.Errorf("unexptected format of latest release: %s", latest)
265 }
266 return strings.TrimPrefix(latest, prefix), nil
267}
268
269func gitTag(ctx context.Context, tag string) error {
270 cmd := exec.CommandContext(ctx, "git", "tag", tag, "-m", tag)

Callers 1

newRepoDataFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected