🚧 This instance is under construction; expect occasional downtime. Runners available in /repos. Questions? Ask in #wikimedia-gitlab on libera.chat, or under GitLab on Phabricator.

Commit d43d6712 authored by Addshore's avatar Addshore 🏄 Committed by Addshore
Browse files

Graciously fail on regular update when no internet

parent 3aad2909
......@@ -19,7 +19,6 @@ package gitlab
import (
"errors"
"fmt"
"net/http"
"runtime"
"time"
......@@ -52,11 +51,9 @@ func wikimediaClient() *gitlab.Client {
/*RelengCliLatestRelease from gitlab*/
func RelengCliLatestRelease() (*gitlab.Release, error) {
// ID 16 in releng/mwcli
releases, response, err := wikimediaClient().Releases.ListReleases(16, nil)
releases, _, err := wikimediaClient().Releases.ListReleases(16, nil)
if err != nil {
fmt.Println(response.Status)
fmt.Println(response.Body)
panic(err)
return nil, err
}
if len(releases) < 1 {
......
......@@ -32,9 +32,12 @@ func CanUpdateFromGitlab(version string, gitSummary string, verboseOutput bool)
selfupdate.EnableLog()
}
latestRelease := latestGitlabRelease()
latestRelease, latestErr := gitlab.RelengCliLatestRelease()
if latestErr != nil {
return false, "Could not fetch latest release version from Gitlab"
}
newVersion, newErr := semver.Parse(strings.Trim(latestRelease, "v"))
newVersion, newErr := semver.Parse(strings.Trim(latestRelease.TagName, "v"))
currentVerion, currentErr := semver.Parse(strings.Trim(version, "v"))
if newErr != nil {
......@@ -47,15 +50,6 @@ func CanUpdateFromGitlab(version string, gitSummary string, verboseOutput bool)
return currentVerion.Compare(newVersion) == -1, newVersion.String()
}
func latestGitlabRelease() string {
release, err := gitlab.RelengCliLatestRelease()
if err != nil {
panic(err)
}
return release.TagName
}
/*UpdateFromGitlab ...*/
func UpdateFromGitlab(currentVersion string, gitSummary string, verboseOutput bool) (success bool, message string) {
if verboseOutput {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment