mirror of
https://github.com/danog/gift.git
synced 2024-11-30 04:19:37 +01:00
Maintaining backward compatibility in clone() signature
This commit is contained in:
parent
d099f2fab2
commit
ab4de6660f
@ -36,7 +36,10 @@ Git.init = (path, bare, callback) ->
|
|||||||
# callback - Receives `(err, repo)`.
|
# callback - Receives `(err, repo)`.
|
||||||
#
|
#
|
||||||
Git.clone = (repository, path, depth = 0, callback) ->
|
Git.clone = (repository, path, depth = 0, callback) ->
|
||||||
if (0 == depth)
|
if typeof depth is 'function'
|
||||||
|
callback = depth
|
||||||
|
depth = 0
|
||||||
|
if depth is 0 or typeof depth isnt 'number'
|
||||||
bash = "git clone \"#{repository}\" \"#{path}\""
|
bash = "git clone \"#{repository}\" \"#{path}\""
|
||||||
else
|
else
|
||||||
bash = "git clone \"#{repository}\" \"#{path}\" --depth \"#{depth}\""
|
bash = "git clone \"#{repository}\" \"#{path}\" --depth \"#{depth}\""
|
||||||
|
@ -44,6 +44,22 @@ describe "git", ->
|
|||||||
@timeout 30000
|
@timeout 30000
|
||||||
repo = null
|
repo = null
|
||||||
newRepositoryDir = "#{__dirname}/fixtures/clone"
|
newRepositoryDir = "#{__dirname}/fixtures/clone"
|
||||||
|
before (done) ->
|
||||||
|
git.clone "https://github.com/notatestuser/gift.git", newRepositoryDir, (err, _repo) ->
|
||||||
|
repo = _repo
|
||||||
|
done err
|
||||||
|
it "clone a repository", (done) ->
|
||||||
|
repo.should.be.an.instanceof Repo
|
||||||
|
repo.remote_list (err, remotes) ->
|
||||||
|
remotes.should.have.length 1
|
||||||
|
done()
|
||||||
|
after (done) ->
|
||||||
|
exec "rm -rf #{newRepositoryDir}", done
|
||||||
|
|
||||||
|
describe "clone() with depth", ->
|
||||||
|
@timeout 30000
|
||||||
|
repo = null
|
||||||
|
newRepositoryDir = "#{__dirname}/fixtures/clone_depth"
|
||||||
before (done) ->
|
before (done) ->
|
||||||
git.clone "https://github.com/notatestuser/gift.git", newRepositoryDir, 1, (err, _repo) ->
|
git.clone "https://github.com/notatestuser/gift.git", newRepositoryDir, 1, (err, _repo) ->
|
||||||
repo = _repo
|
repo = _repo
|
||||||
|
Loading…
Reference in New Issue
Block a user