Skip to content

Commit

Permalink
[usage/update] Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Oct 4, 2024
1 parent 7a583ae commit 3e5f31f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions usage/update/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ func getLatestGitHubRelease(app, version, repository string) *githubRelease {
engine.SetDialTimeout(3)
engine.SetRequestTimeout(3)

response, err := engine.Get(req.Request{
resp, err := engine.Get(req.Request{
URL: githubAPI + "/repos/" + repository + "/releases/latest",
Headers: req.Headers{"X-GitHub-Api-Version": "2022-11-28"},
AutoDiscard: true,
})

if err != nil || response.StatusCode != 200 {
if err != nil || resp.StatusCode != 200 {
return nil
}

if response.Header.Get("X-RateLimit-Remaining") == "0" {
if resp.Header.Get("X-RateLimit-Remaining") == "0" {
return nil
}

release := &githubRelease{}
err = response.JSON(release)
err = resp.JSON(release)

if err != nil {
return nil
Expand Down
8 changes: 4 additions & 4 deletions usage/update/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ func getLatestGitLabRelease(app, version, repository string) *gitlabRelease {
repository = strings.ReplaceAll(repository, "/", "%2F")
}

response, err := engine.Get(req.Request{
resp, err := engine.Get(req.Request{
URL: gitlabAPI + "/projects/" + repository + "/releases/permalink/latest",
AutoDiscard: true,
})

if err != nil || response.StatusCode != 200 {
if err != nil || resp.StatusCode != 200 {
return nil
}

if response.Header.Get("RateLimit-Remaining") == "0" {
if resp.Header.Get("RateLimit-Remaining") == "0" {
return nil
}

release := &gitlabRelease{}
err = response.JSON(release)
err = resp.JSON(release)

if err != nil {
return nil
Expand Down

0 comments on commit 3e5f31f

Please sign in to comment.