Commit 9cb99b74 authored by Nong Hoang Tu's avatar Nong Hoang Tu
Browse files

Add logic for update all

parent a2512fd6
...@@ -5,11 +5,40 @@ import os ...@@ -5,11 +5,40 @@ import os
proc doUpdateProject(config: ProgConf, project: DebPackage): Err = proc doUpdateProject(config: ProgConf, project: DebPackage): Err =
var stderr: string
if gbpPull(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while pulling", stderr)
return Err.failed
var localVer, serverVer: string var localVer, serverVer: string
let updateStt = checkUpdate(config.uscanPath, project.path, localVer, serverVer) let updateStt = checkUpdate(config.uscanPath, project.path, localVer, serverVer, stderr)
if updateStt == Err.updated: if updateStt == Err.updated:
project.log.logInfo(project.name, "Up to date") project.log.logInfo(project.name, "Up to date")
return updateStt return Err.updated
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)
if gbpUpdate(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while updating", stderr)
return Err.failed
if gbpDch(config.uscanPath, project.path, serverVer, stderr) != 0:
project.log.logErr(project.name, "Error while creating new changelog", stderr)
return Err.failed
if gbpTag(config.uscanPath, project.path, stderr) != 0:
project.log.logErr(project.name, "Error while creating new tag", stderr)
return Err.failed
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
proc updateProjectAll(config: ProgConf) = proc updateProjectAll(config: ProgConf) =
...@@ -25,10 +54,10 @@ proc updateProjectAll(config: ProgConf) = ...@@ -25,10 +54,10 @@ proc updateProjectAll(config: ProgConf) =
let updateResult = doUpdateProject(config, project) let updateResult = doUpdateProject(config, project)
if updateResult == Err.updated: if updateResult == Err.updated:
resultLog.logInfo(project.name, "Up to date") resultLog.logInfo(project.name, "Up to date")
# if doUpdateProject(project): elif updateResult == Err.updateSuccess:
# # TODO use more status return for update status resultLog.logInfo(project.name, "Update successfully")
# # resultLog.logInfo(project.name, " Update success") else:
# discard resultLog.logErr(project.name, "Failed to update", "")
proc updateProjectArr(config: ProgConf) = proc updateProjectArr(config: ProgConf) =
......
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