Improves cloning of git repositories. Refs #70.
This commit is contained in:
parent
42dcac241f
commit
a0fb2c173b
1 changed files with 17 additions and 10 deletions
|
|
@ -42,21 +42,28 @@ proc doPull(meth: TDownloadMethod, downloadDir: string) =
|
||||||
doCmd("hg pull")
|
doCmd("hg pull")
|
||||||
|
|
||||||
proc doClone(meth: TDownloadMethod, url, downloadDir: string, branch = "", tip = true) =
|
proc doClone(meth: TDownloadMethod, url, downloadDir: string, branch = "", tip = true) =
|
||||||
let branchArg = if branch == "": "" else: "-b " & branch & " "
|
|
||||||
case meth
|
case meth
|
||||||
of TDownloadMethod.Git:
|
of TDownloadMethod.Git:
|
||||||
let depthArg = if tip: "--depth 1 " else: ""
|
let
|
||||||
# TODO: Get rid of the annoying 'detached HEAD' message somehow?
|
depthArg = if tip: "--depth 1 " else: ""
|
||||||
doCmd("git clone --recursive " & depthArg & branchArg & url &
|
branchArg = if branch == "": "-b origin/master" else: "-b " & branch & " "
|
||||||
" " & downloadDir)
|
branch = if branch == "": "master" else: branch
|
||||||
# Some git versions (e.g. 1.7.9.5) don't check out the correct branch/tag
|
# Some git versions (e.g. 1.7.9.5) don't check out the correct branch/tag
|
||||||
# directly during clone, so we enter the download directory and forecefully
|
# directly during clone, so we enter the download directory and manually
|
||||||
# check it out just in case.
|
# initi the git repo issuing several commands in sequence. Recipe taken
|
||||||
cd downloadDir:
|
# from http://stackoverflow.com/a/3489576/172690.
|
||||||
doCmd("git checkout --force " & branch)
|
downloadDir.createDir
|
||||||
|
downloadDir.cd:
|
||||||
|
doCmd("git init")
|
||||||
|
doCmd("git remote add origin " & url)
|
||||||
|
doCmd("git fetch origin " & depthArg & branch)
|
||||||
|
doCmd("git reset --hard FETCH_HEAD")
|
||||||
|
doCmd("git checkout --force " & branchArg)
|
||||||
doCmd("git submodule update --init --recursive")
|
doCmd("git submodule update --init --recursive")
|
||||||
of TDownloadMethod.Hg:
|
of TDownloadMethod.Hg:
|
||||||
let tipArg = if tip: "-r tip " else: ""
|
let
|
||||||
|
tipArg = if tip: "-r tip " else: ""
|
||||||
|
branchArg = if branch == "": "" else: "-b " & branch & " "
|
||||||
doCmd("hg clone " & tipArg & branchArg & url & " " & downloadDir)
|
doCmd("hg clone " & tipArg & branchArg & url & " " & downloadDir)
|
||||||
|
|
||||||
proc getTagsList(dir: string, meth: TDownloadMethod): seq[string] =
|
proc getTagsList(dir: string, meth: TDownloadMethod): seq[string] =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue