mirror of
https://github.com/Luzifer/go-latestver.git
synced 2024-12-20 18:41:17 +00:00
Fix version compare failing when old version is not present
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
2e88a0b090
commit
994d2d2aba
2 changed files with 6 additions and 1 deletions
|
@ -26,6 +26,11 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c Constraint) ShouldApply(oldVersion, newVersion string) (bool, error) {
|
func (c Constraint) ShouldApply(oldVersion, newVersion string) (bool, error) {
|
||||||
|
if oldVersion == "" && newVersion != "" {
|
||||||
|
// The old version does not exist, the new one does, update it!
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
comp := c.getComparer()
|
comp := c.getComparer()
|
||||||
if comp == nil {
|
if comp == nil {
|
||||||
return false, errors.New("invalid version type specified")
|
return false, errors.New("invalid version type specified")
|
||||||
|
|
|
@ -79,7 +79,7 @@ func checkForUpdates(ce *database.CatalogEntry) error {
|
||||||
cm.Error = err.Error()
|
cm.Error = err.Error()
|
||||||
|
|
||||||
case compareErr != nil:
|
case compareErr != nil:
|
||||||
logger.WithError(err).Error("Version compare caused error, error is stored in entry")
|
logger.WithError(compareErr).Error("Version compare caused error, error is stored in entry")
|
||||||
cm.Error = compareErr.Error()
|
cm.Error = compareErr.Error()
|
||||||
|
|
||||||
case cm.CurrentVersion != ver && !shouldUpdate:
|
case cm.CurrentVersion != ver && !shouldUpdate:
|
||||||
|
|
Loading…
Reference in a new issue