MCPcopy Index your code
hub / github.com/dagger/dagger / matchVersion

Function matchVersion

core/schema/modulesource.go:3561–3578  ·  view source on GitHub ↗

Match a version string in a list of versions with optional subPath e.g. github.com/foo/daggerverse/mod@mod/v1.0.0 e.g. github.com/foo/mod@v1.0.0 TODO smarter matching logic, e.g. v1 == v1.0.0

(versions []string, match, subPath string)

Source from the content-addressed store, hash-verified

3559// e.g. github.com/foo/mod@v1.0.0
3560// TODO smarter matching logic, e.g. v1 == v1.0.0
3561func matchVersion(versions []string, match, subPath string) (string, error) {
3562 // If theres a subPath, first match on {subPath}/{match} for monorepo tags
3563 if subPath != "/" {
3564 rawSubPath, _ := strings.CutPrefix(subPath, "/")
3565 matched, err := matchVersion(versions, fmt.Sprintf("%s/%s", rawSubPath, match), "/")
3566 // no error means there's a match with subpath/match
3567 if err == nil {
3568 return matched, nil
3569 }
3570 }
3571
3572 for _, v := range versions {
3573 if v == match {
3574 return v, nil
3575 }
3576 }
3577 return "", fmt.Errorf("unable to find version %s", match)
3578}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected