Commit 7a12fcfa authored by Nong Hoang Tu's avatar Nong Hoang Tu
Browse files

add full log to success

parent 143b3627
......@@ -5,13 +5,14 @@ import os
proc doUpdateProject(config: ProgConf, project: DebPackage): Err =
var stderr: string
var stderr, localVer, serverVer: string
if gbpPull(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while pulling", stderr)
return Err.failed
else:
project.log.logInfo(project.name, "Pull completed. Start checking new update")
var localVer, serverVer: string
let updateStt = checkUpdate(config.uscanPath, project.path, localVer, serverVer, stderr)
if updateStt == Err.updated:
project.log.logInfo(project.name, "Up to date")
......@@ -19,26 +20,33 @@ proc doUpdateProject(config: ProgConf, project: DebPackage): Err =
elif updateStt == Err.checkVersionErr:
project.log.logErr(project.name, "Error while checking for new version", stderr)
return Err.updated
project.log.logInfo(project.name, "local version: " & localVer & " server version: " & serverVer)
else:
project.log.logInfo(project.name, "[" & localVer & "] [" & serverVer & "]. Start upgrading source code.")
if gbpUpdate(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while updating", stderr)
return Err.failed
else:
project.log.logInfo(project.name, "Upgrade to new version successfully. Making changelog.")
if gbpDch(config.uscanPath, project.path, serverVer, stderr) != 0:
project.log.logErr(project.name, "Error while creating new changelog", stderr)
return Err.failed
else:
project.log.logInfo(project.name, "New changelog was created. Making new tag.")
if gbpTag(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while creating new tag", stderr)
return Err.failed
else:
project.log.logInfo(project.name, "Create new tag successfully. Start pushing.")
if gbpPush(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while pushing new patches", stderr)
return Err.failed
return Err.updateSuccess
else:
project.log.logInfo(project.name, "Pushed new version to " & dirName(config.gitUrl) & project.name)
return Err.updateSuccess
proc updateProjectAll(config: ProgConf) =
......@@ -82,11 +90,35 @@ proc updateProjectArr(config: ProgConf, projectArr: seq[string]) =
proc pullProjectAll(config: ProgConf) =
discard
let
fullLog = initFullLogs(config.logPath)
var
project: DebPackage
stderr: string
project.log = fullLog
for kind, path in walkDir(config.rootPath):
if kind == pcDir:
project.path = path
project.name = path.splitPath.tail
if gbpPull(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while pulling", stderr)
proc pullProjectArr(config: ProgConf) =
discard
proc pullProjectArr(config: ProgConf, projectArr: seq[string]) =
let
fullLog = initFullLogs(config.logPath)
var
project: DebPackage
stderr: string
project.log = fullLog
for name in projectArr:
project.name = name
project.path = config.rootPath & name & "/"
if not dirExists(project.path):
project.log.logErr(project.name, "Dir doesn't exist", "")
else:
if gbpPull(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while pulling", stderr)
proc cloneProject*() =
......@@ -110,5 +142,4 @@ proc handlePullProject*(projects: seq[string]) =
if len(projects) == 0:
pullProjectAll(config)
else:
pullProjectArr(config)
discard
pullProjectArr(config, projects)
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