Commit 04511a68 authored by Nong Hoang Tu's avatar Nong Hoang Tu

Fix compare version problem

parent ef9cfd2c
Pipeline #2121 failed with stages
import logutils
import core
import verutils
proc cmpVersionWatch*(updater: DebProject, version: var string): int =
# TODO get version name but with error code for:
# 1. Update error
# 2. No update (same version)
# 3. any other errors
let localVersion = localVersion(updater.path)
if localVersion != "":
updater.logInfo("Found local version [watch file] " & localVersion)
else:
updater.logError("Can't get local version")
return ERR
let siteVersion = parseWatchVersion(updater.path & "/debian/watch")
if siteVersion == "":
updater.logError("Can't get website version")
return ERR
else:
updater.logInfo("Found online version [watch file] " & siteVersion)
version = siteVersion
if localVersion != siteVersion:
updater.logInfo("Different version [" & localVersion & "] [" & siteVersion & "]")
return OUTOFDATED
else:
updater.logInfo("Same version from local and server")
return UPTODATED
......@@ -7,6 +7,7 @@ import parseutils
import httpClient
import regex
import core
import osproc
proc parseVersion(line: string): string =
......@@ -127,3 +128,20 @@ proc parseWatchVersion*(path: string): string =
return ""
except:
return ""
proc parseUscanOutput(line: string): array[2, string] =
let tmpLine = line.split(",")
let serverVersion = tmpLine[0].split(" ")[^1]
let localVersion = tmpLine[1].split(" ")[^1]
return [serverVersion, localVersion]
proc parseVersionByUscan*(path: string): array[2, string] =
let
command = "uscan --no-download"
output = execProcess(command, path)
for line in output.split("\n"):
if line.startsWith("uscan:") and "Newest version" in line:
return parseUscanOutput(line)
return ["", ""]
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