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 ...@@ -19,7 +19,6 @@ package gitlab
import ( import (
"errors" "errors"
"fmt"
"net/http" "net/http"
"runtime" "runtime"
"time" "time"
...@@ -52,11 +51,9 @@ func wikimediaClient() *gitlab.Client { ...@@ -52,11 +51,9 @@ func wikimediaClient() *gitlab.Client {
/*RelengCliLatestRelease from gitlab*/ /*RelengCliLatestRelease from gitlab*/
func RelengCliLatestRelease() (*gitlab.Release, error) { func RelengCliLatestRelease() (*gitlab.Release, error) {
// ID 16 in releng/mwcli // ID 16 in releng/mwcli
releases, response, err := wikimediaClient().Releases.ListReleases(16, nil) releases, _, err := wikimediaClient().Releases.ListReleases(16, nil)
if err != nil { if err != nil {
fmt.Println(response.Status) return nil, err
fmt.Println(response.Body)
panic(err)
} }
if len(releases) < 1 { if len(releases) < 1 {
......
...@@ -32,9 +32,12 @@ func CanUpdateFromGitlab(version string, gitSummary string, verboseOutput bool) ...@@ -32,9 +32,12 @@ func CanUpdateFromGitlab(version string, gitSummary string, verboseOutput bool)
selfupdate.EnableLog() 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")) currentVerion, currentErr := semver.Parse(strings.Trim(version, "v"))
if newErr != nil { if newErr != nil {
...@@ -47,15 +50,6 @@ func CanUpdateFromGitlab(version string, gitSummary string, verboseOutput bool) ...@@ -47,15 +50,6 @@ func CanUpdateFromGitlab(version string, gitSummary string, verboseOutput bool)
return currentVerion.Compare(newVersion) == -1, newVersion.String() return currentVerion.Compare(newVersion) == -1, newVersion.String()
} }
func latestGitlabRelease() string {
release, err := gitlab.RelengCliLatestRelease()
if err != nil {
panic(err)
}
return release.TagName
}
/*UpdateFromGitlab ...*/ /*UpdateFromGitlab ...*/
func UpdateFromGitlab(currentVersion string, gitSummary string, verboseOutput bool) (success bool, message string) { func UpdateFromGitlab(currentVersion string, gitSummary string, verboseOutput bool) (success bool, message string) {
if verboseOutput { if verboseOutput {
......
Supports Markdown
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