mirror of
https://github.com/danog/gift.git
synced 2024-11-30 04:19:37 +01:00
Support git's shallow clone
This commit is contained in:
parent
e414fc518d
commit
d099f2fab2
@ -38,7 +38,7 @@ Clone a repository:
|
||||
|
||||
git = require 'gift'
|
||||
|
||||
git.clone "git@host:path/to/remote/repo.git", "path/to/local/clone/repo", (err, _repo) ->
|
||||
git.clone "git@host:path/to/remote/repo.git", "path/to/local/clone/repo", depth, (err, _repo) ->
|
||||
repo = _repo
|
||||
# => #<Repo>
|
||||
|
||||
|
@ -32,10 +32,14 @@ Git.init = (path, bare, callback) ->
|
||||
#
|
||||
# repository - The repository to clone from.
|
||||
# path - The directory to clone into.
|
||||
# depth - The specified number of revisions of shallow clone
|
||||
# callback - Receives `(err, repo)`.
|
||||
#
|
||||
Git.clone = (repository, path, callback) ->
|
||||
bash = "git clone \"#{repository}\" \"#{path}\""
|
||||
Git.clone = (repository, path, depth = 0, callback) ->
|
||||
if (0 == depth)
|
||||
bash = "git clone \"#{repository}\" \"#{path}\""
|
||||
else
|
||||
bash = "git clone \"#{repository}\" \"#{path}\" --depth \"#{depth}\""
|
||||
exec bash, (err, stdout, stderr) ->
|
||||
return callback err if err
|
||||
return callback err, (new Repo path, false, { maxBuffer: Git.maxBuffer })
|
||||
|
@ -45,7 +45,7 @@ describe "git", ->
|
||||
repo = null
|
||||
newRepositoryDir = "#{__dirname}/fixtures/clone"
|
||||
before (done) ->
|
||||
git.clone "https://github.com/notatestuser/gift.git", newRepositoryDir, (err, _repo) ->
|
||||
git.clone "https://github.com/notatestuser/gift.git", newRepositoryDir, 1, (err, _repo) ->
|
||||
repo = _repo
|
||||
done err
|
||||
it "clone a repository", (done) ->
|
||||
|
Loading…
Reference in New Issue
Block a user