MCPcopy Create free account
hub / github.com/github/gh-aw / parseInstalledVersionOutput

Function parseInstalledVersionOutput

pkg/cli/update_extension_check.go:538–545  ·  view source on GitHub ↗

parseInstalledVersionOutput scans the output of `gh aw version` for the first token that is a valid semantic version (with or without a leading "v"). It returns the version normalized to include a "v" prefix.

(output string)

Source from the content-addressed store, hash-verified

536// first token that is a valid semantic version (with or without a leading "v").
537// It returns the version normalized to include a "v" prefix.
538func parseInstalledVersionOutput(output string) (string, error) {
539 for token := range strings.FieldsSeq(output) {
540 if semverutil.IsValid(token) {
541 return semverutil.EnsureVPrefix(token), nil
542 }
543 }
544 return "", fmt.Errorf("could not parse installed gh-aw version from output: %s", summarizeCommandOutput(output))
545}
546
547func summarizeCommandOutput(output string) string {
548 const maxOutputLen = 300

Callers 2

Calls 4

IsValidFunction · 0.92
EnsureVPrefixFunction · 0.92
summarizeCommandOutputFunction · 0.85
ErrorfMethod · 0.45

Tested by 1