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

Method FetchLatestRelease

internal/pluginstore/github.go:58–77  ·  view source on GitHub ↗

FetchLatestRelease returns the latest published release of the plugin's GitHub repository, mirroring the WebUI panel update check.

(ctx context.Context, plugin Plugin)

Source from the content-addressed store, hash-verified

56// FetchLatestRelease returns the latest published release of the plugin's
57// GitHub repository, mirroring the WebUI panel update check.
58func (c Client) FetchLatestRelease(ctx context.Context, plugin Plugin) (Release, error) {
59 owner, repo, errRepository := GitHubRepositoryParts(plugin.Repository)
60 if errRepository != nil {
61 return Release{}, errRepository
62 }
63 releaseURL := fmt.Sprintf(
64 "https://api.github.com/repos/%s/%s/releases/latest",
65 url.PathEscape(owner),
66 url.PathEscape(repo),
67 )
68 data, errDownload := c.get(ctx, releaseURL, "application/vnd.github+json", RequestKindMetadata, 0)
69 if errDownload != nil {
70 return Release{}, errDownload
71 }
72 var release Release
73 if errDecode := json.Unmarshal(data, &release); errDecode != nil {
74 return Release{}, fmt.Errorf("decode release: %w", errDecode)
75 }
76 return release, nil
77}
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) {

Callers 2

InstallMethod · 0.95
latestPluginVersionMethod · 0.45

Calls 2

getMethod · 0.95
GitHubRepositoryPartsFunction · 0.85

Tested by

no test coverage detected