MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / FetchReleaseByTag

Method FetchReleaseByTag

internal/pluginstore/github.go:80–104  ·  view source on GitHub ↗

FetchReleaseByTag returns a published release by its exact GitHub tag.

(ctx context.Context, plugin Plugin, tag string)

Source from the content-addressed store, hash-verified

78
79// FetchReleaseByTag returns a published release by its exact GitHub tag.
80func (c Client) FetchReleaseByTag(ctx context.Context, plugin Plugin, tag string) (Release, error) {
81 owner, repo, errRepository := GitHubRepositoryParts(plugin.Repository)
82 if errRepository != nil {
83 return Release{}, errRepository
84 }
85 tag = strings.TrimSpace(tag)
86 if tag == "" {
87 return Release{}, fmt.Errorf("release tag is required")
88 }
89 releaseURL := fmt.Sprintf(
90 "https://api.github.com/repos/%s/%s/releases/tags/%s",
91 url.PathEscape(owner),
92 url.PathEscape(repo),
93 url.PathEscape(tag),
94 )
95 data, errDownload := c.get(ctx, releaseURL, "application/vnd.github+json", RequestKindMetadata, 0)
96 if errDownload != nil {
97 return Release{}, errDownload
98 }
99 var release Release
100 if errDecode := json.Unmarshal(data, &release); errDecode != nil {
101 return Release{}, fmt.Errorf("decode release: %w", errDecode)
102 }
103 return release, nil
104}
105
106// ReleaseVersion derives the plugin version from the release tag, stripping a
107// leading "v"/"V" and validating the result.

Callers 1

InstallVersionMethod · 0.95

Calls 2

getMethod · 0.95
GitHubRepositoryPartsFunction · 0.85

Tested by

no test coverage detected