1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00

better error for nonbackwards compatible changes

This commit is contained in:
Jesse Duffield 2018-09-01 10:36:22 +10:00
parent d8aba3aeee
commit 42500817e0
2 changed files with 13 additions and 5 deletions

View File

@ -329,7 +329,7 @@ func addEnglish(i18nObject *i18n.Bundle) error {
Other: "You already have the latest version",
}, &i18n.Message{
ID: "MajorVersionErr",
Other: "New version has non-backwards compatible changes.",
Other: "New version ({{.newVersion}}) has non-backwards compatible changes compared to the current version ({{.currentVersion}})",
}, &i18n.Message{
ID: "CouldNotFindBinaryErr",
Other: "Could not find any binary at {{.url}}",

View File

@ -96,6 +96,7 @@ func (u *Updater) majorVersionDiffers(oldVersion, newVersion string) bool {
func (u *Updater) checkForNewUpdate() (string, error) {
u.Log.Info("Checking for an updated version")
currentVersion := u.Config.GetVersion()
if err := u.RecordLastUpdateCheck(); err != nil {
return "", err
}
@ -104,15 +105,22 @@ func (u *Updater) checkForNewUpdate() (string, error) {
if err != nil {
return "", err
}
u.Log.Info("Current version is " + u.Config.GetVersion())
u.Log.Info("Current version is " + currentVersion)
u.Log.Info("New version is " + newVersion)
if newVersion == u.Config.GetVersion() {
if newVersion == currentVersion {
return "", errors.New(u.Tr.SLocalize("OnLatestVersionErr"))
}
if u.majorVersionDiffers(u.Config.GetVersion(), newVersion) {
return "", errors.New(u.Tr.SLocalize("MajorVersionErr"))
if u.majorVersionDiffers(currentVersion, newVersion) {
errMessage := u.Tr.TemplateLocalize(
"MajorVersionErr",
i18n.Teml{
"newVersion": newVersion,
"currentVersion": currentVersion,
},
)
return "", errors.New(errMessage)
}
rawUrl, err := u.getBinaryUrl(newVersion)