diff options
author | Amrykid <amrykid@gmail.com> | 2011-12-25 14:37:10 -0600 |
---|---|---|
committer | Amrykid <amrykid@gmail.com> | 2011-12-25 14:45:03 -0600 |
commit | d0d0c79540c4c887935b39c3ced5fdf01f2900d1 (patch) | |
tree | ff2c798aa810e9c0cdb7447875f354ff15a88ee5 /koch.nim | |
parent | f0ccc2e779bb6e5db15b7a19efe90d99b6518b3e (diff) | |
download | Nim-d0d0c79540c4c887935b39c3ced5fdf01f2900d1.tar.gz |
Final bits added. Needs testing.
Diffstat (limited to 'koch.nim')
-rwxr-xr-x | koch.nim | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/koch.nim b/koch.nim index 1af3a4d86..98c9b7202 100755 --- a/koch.nim +++ b/koch.nim @@ -11,7 +11,7 @@ when defined(gcc) and defined(windows): {.link: "icons/koch.res".} import - os, strutils, parseopt, osproc, httpclient + os, strutils, parseopt, osproc, httpclient, streams when defined(haveZipLib): import zipfiles @@ -45,6 +45,8 @@ Boot options: -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 exec(cmd: string) = @@ -82,26 +84,39 @@ proc web(args: string) = NimrodVersion) 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 git = findExe("git") echo("Checking for git repo...") - if existsDir(thisDir & "/.git"): + if existsDir(thisDir & "/.git") and git != "": echo("Git repo found!") # use git to download latest source - var output = execProcess("git diff origin/master master") - if output == "\r\n": - # No changes - echo("No update. Exiting..") - return + discard startCmd(git & " fetch origin master") + var procs = startCmd(git & " diff origin/master master") + var errcode = procs.waitForExit() + var output = readLine(procs.outputStream) + echo(output) + if errcode == 0: + if output == "": + # No changes + echo("No update. Exiting..") + return + else: + echo("Fetching updates from repo...") + var pullout = execCmdEx(git & " pull origin master") + 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("Fetching updates from repo...") - var pullout = execCmdEx("git pull origin master") - 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: @@ -123,7 +138,7 @@ proc update(args: string) = return echo("Starting update...") - exec("./koch boot -d:release") + boot(args) echo("Update complete!") |