Final bits added. Needs testing.

This commit is contained in:
Amrykid 2011-12-25 14:37:10 -06:00
commit d0d0c79540

View file

@ -11,7 +11,7 @@ when defined(gcc) and defined(windows):
{.link: "icons/koch.res".} {.link: "icons/koch.res".}
import import
os, strutils, parseopt, osproc, httpclient os, strutils, parseopt, osproc, httpclient, streams
when defined(haveZipLib): when defined(haveZipLib):
import zipfiles import zipfiles
@ -45,6 +45,8 @@ Boot options:
-d:nativeStacktrace use native stack traces (only for Mac OS X or Linux) -d:nativeStacktrace use native stack traces (only for Mac OS X or Linux)
""" """
proc boot(args: string) # Forward declaration
proc exe(f: string): string = return addFileExt(f, ExeExt) proc exe(f: string): string = return addFileExt(f, ExeExt)
proc exec(cmd: string) = proc exec(cmd: string) =
@ -82,26 +84,39 @@ proc web(args: string) =
NimrodVersion) NimrodVersion)
proc update(args: string) = proc update(args: string) =
when defined(windows):
echo("Windows Users: Make sure to be running this in Bash. If you aren't, press CTRL+C now.")
var thisDir = getAppDir() var thisDir = getAppDir()
var git = findExe("git")
echo("Checking for git repo...") echo("Checking for git repo...")
if existsDir(thisDir & "/.git"): if existsDir(thisDir & "/.git") and git != "":
echo("Git repo found!") echo("Git repo found!")
# use git to download latest source # use git to download latest source
var output = execProcess("git diff origin/master master") discard startCmd(git & " fetch origin master")
if output == "\r\n": var procs = startCmd(git & " diff origin/master master")
# No changes var errcode = procs.waitForExit()
echo("No update. Exiting..") var output = readLine(procs.outputStream)
return echo(output)
else: if errcode == 0:
echo("Fetching updates from repo...") if output == "":
var pullout = execCmdEx("git pull origin master") # No changes
if pullout[1] != 0: echo("No update. Exiting..")
echo("An error has occured.")
return return
else: else:
if pullout[0] == "Already up-to-date.\r\n": echo("Fetching updates from repo...")
echo("No new changes fetched from the repo. Local branch must be ahead of it. Exiting...") var pullout = execCmdEx(git & " pull origin master")
return if pullout[1] != 0:
echo("An error has occured.")
return
else:
if pullout[0] == "Already up-to-date.\r\n":
echo("No new changes fetched from the repo. Local branch must be ahead of it. Exiting...")
return
else:
echo("An error has occured.")
return
else: else:
@ -123,7 +138,7 @@ proc update(args: string) =
return return
echo("Starting update...") echo("Starting update...")
exec("./koch boot -d:release") boot(args)
echo("Update complete!") echo("Update complete!")