Skip to content

Commit

Permalink
Fixes cloning of default git branches.
Browse files Browse the repository at this point in the history
When cloning a git repo the default branch will now be cloned.
Had to revert #70 for this. Sorry @gradha.
  • Loading branch information
dom96 committed Jun 14, 2015
1 parent 3a66241 commit 1234cdc
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/nimblepkg/download.nim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ proc doCheckout(meth: DownloadMethod, downloadDir, branch: string) =
proc doPull(meth: DownloadMethod, downloadDir: string) =
case meth
of DownloadMethod.git:
doCheckout(meth, downloadDir, "master")
doCheckout(meth, downloadDir, "")
cd downloadDir:
doCmd("git pull")
if existsFile(".gitmodules"):
Expand All @@ -47,20 +47,9 @@ proc doClone(meth: DownloadMethod, url, downloadDir: string, branch = "",
of DownloadMethod.git:
let
depthArg = if tip: "--depth 1 " else: ""
branchArg = if branch == "": "-b origin/master" else: "-b " & branch & " "
branch = if branch == "": "master" else: branch
# 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 manually
# initi the git repo issuing several commands in sequence. Recipe taken
# from http://stackoverflow.com/a/3489576/172690.
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")
branchArg = if branch == "": "" else: "-b " & branch & " "
doCmd("git clone --recursive " & depthArg & branchArg & url &
" " & downloadDir)
of DownloadMethod.hg:
let
tipArg = if tip: "-r tip " else: ""
Expand Down

0 comments on commit 1234cdc

Please sign in to comment.