Commit 7e507b62881919d5f9eeb22c2fd4fa72a2859564

Authored by Göran Krampe
1 parent 3e2f4c14

Fixes discovered while testing on windows XP.

Showing 1 changed file with 23 additions and 15 deletions
blimp.nim
... ... @@ -41,10 +41,10 @@ password = "some-good-rsync-password-for-blimpuser"
41 41 # The following three formats should not need editing.
42 42 # $1 is the blimp filename, $2 is remote location and $3 is the local blimpstore directory set above.
43 43 # NOTE: The password-file .blimp.pass will be created by blimp on every command, do not remove that option.
44   -upload = "rsync --password-file $3/.blimp.pass -avzP $3/$1 $2/"
45   -download = "rsync --password-file $3/.blimp.pass -avzP $2/$1 $3/"
  44 +upload = "rsync --password-file $3/.blimp.pass -azP $3/$1 $2/"
  45 +download = "rsync --password-file $3/.blimp.pass -azP $2/$1 $3/"
46 46 # This deletes a single file from destination, that is already deleted in source. Yeah... insane! But it works.
47   -delete = "rsync --password-file $3/.blimp.pass -dv --delete --existing --ignore-existing --include '$1' --exclude '*' $3/ $2"
  47 +delete = "rsync --password-file $3/.blimp.pass -d --delete --existing --ignore-existing --include '$1' --exclude '*' $3/ $2"
48 48  
49 49 [blimp]
50 50 # Minimal version, otherwise stop
... ... @@ -53,7 +53,12 @@ delete = "rsync --password-file $3/.blimp.pass -dv --delete --existing --ignore-
53 53  
54 54 proc cmd(cmd: string): string =
55 55 try:
56   - let tup = execCmdEx(cmd)
  56 + # Otherwise pipes will not work for git commands etc
  57 + when defined(windows):
  58 + let tup = execCmdEx("cmd /c \"" & cmd & "\"")
  59 + else:
  60 + let tup = execCmdEx(cmd)
  61 + #echo "cmd: " & $cmd & "err:" & $tup[1]
57 62 if tup[1] == 0:
58 63 result = strip(tup[0])
59 64 else:
... ... @@ -139,7 +144,7 @@ proc run(cmd: string): auto =
139 144 proc rsyncRun(cmd: string): auto =
140 145 if not rsyncPassword.isNil:
141 146 writeFile(blimpStore / ".blimp.pass", rsyncPassword)
142   - if execCmd("chmod 600 " & blimpStore / ".blimp.pass") != 0:
  147 + if execCmd("chmod 600 \"" & blimpStore / ".blimp.pass\"") != 0:
143 148 quit("Failed to chmod 600 " & blimpStore / ".blimp.pass")
144 149 run(cmd)
145 150  
... ... @@ -244,14 +249,14 @@ proc deflate(filename: string) =
244 249  
245 250 # Iterator over all deflated files in the git clone
246 251 iterator allDeflated() =
247   - let filenames = cmd("git ls-files " & gitRootDir).split('\l')
  252 + let filenames = cmd("git ls-files " & gitRootDir).split({'\l', '\c'})
248 253 for fn in filenames:
249 254 if not blimpFilename(fn).isNil:
250 255 yield fn
251 256  
252 257 # Iterator over all files matching the blimp filter in the git clone
253 258 iterator allFiltered() =
254   - let lines = cmd("git ls-files | git check-attr --stdin filter").split('\l')
  259 + let lines = cmd("git ls-files | git check-attr --stdin filter").split({'\l', '\c'})
255 260 for line in lines:
256 261 let status = line.split(':')
257 262 if strip(status[2]) == "blimp":
... ... @@ -310,11 +315,11 @@ proc `$`(x: string): string =
310 315  
311 316 proc dumpConfig() =
312 317 echo "\nDump of configuration:"
313   - echo "\tblimpStore: " & blimpStore
314   - echo "\tremoteBlimpStore: " & remoteBlimpStore
315   - echo "\tuploadCommandFormat: " & uploadCommandFormat
316   - echo "\tdownloadCommandFormat: " & downloadCommandFormat
317   - echo "\tdeleteCommandFormat: " & deleteCommandFormat
  318 + echo "\tblimpStore: " & $blimpStore
  319 + echo "\tremoteBlimpStore: " & $remoteBlimpStore
  320 + echo "\tuploadCommandFormat: " & $uploadCommandFormat
  321 + echo "\tdownloadCommandFormat: " & $downloadCommandFormat
  322 + echo "\tdeleteCommandFormat: " & $deleteCommandFormat
318 323 echo "\trsyncPassword: " & $rsyncPassword
319 324 echo "\tblimpVersion: " & $blimpVersion
320 325 echo "\n"
... ... @@ -418,6 +423,7 @@ homeDir = getHomeDir()
418 423 homeDir = homeDir[0.. -2] # Not sure why it keeps a trailing "/" on Linux
419 424 currentDir = getCurrentDir()
420 425 gitRootDir = gitRoot()
  426 +echo gitRootDir
421 427  
422 428 # Using lapp to get args, on parsing failure this will show usage automatically
423 429 var args = parse(synopsis)
... ... @@ -442,13 +448,15 @@ parseConfFile(currentDir / ".blimp.conf")
442 448 if not gitRootDir.isNil and gitRootDir != currentDir:
443 449 parseConfFile(gitRootDir / ".blimp.conf")
444 450  
  451 +if existsDir(homeDir / "blimpstore"):
  452 + parseConfFile(homeDir / "blimpstore" / ".blimp.conf")
  453 +
  454 +parseConfFile(homeDir / ".blimp.conf")
  455 +
445 456 # If we haven't gotten a blimpstore yet, we set a default one
446 457 if blimpStore.isNil:
447 458 blimpStore = homeDir / "blimpstore"
448 459  
449   -if existsDir(blimpStore):
450   - parseConfFile(blimpStore / ".blimp.conf")
451   -parseConfFile(homeDir / ".blimp.conf")
452 460  
453 461 # Let's just show what we have :)
454 462 if verbose: dumpConfig()
... ...