From 1234cdce13c1f1b25da7980099cffd7f39b54326 Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Sun, 14 Jun 2015 18:44:17 +0100 Subject: [PATCH] Fixes cloning of default git branches. When cloning a git repo the default branch will now be cloned. Had to revert #70 for this. Sorry @gradha. --- src/nimblepkg/download.nim | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/nimblepkg/download.nim b/src/nimblepkg/download.nim index dfb331f..a7ebd34 100644 --- a/src/nimblepkg/download.nim +++ b/src/nimblepkg/download.nim @@ -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"): @@ -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: ""