mirror of
https://github.com/danog/gift.git
synced 2024-11-30 04:19:37 +01:00
Git.clone() added
* Wrapper for `git clone` command. * Test added and custom 30000 timeout is set to it as cloning requires quite some time. * Documentation updated.
This commit is contained in:
parent
9503fc8208
commit
a197fe7ba0
@ -16,6 +16,15 @@ A simple Node.js wrapper for the Git CLI. The API is based on
|
||||
repo = git "path/to/repo"
|
||||
# => #<Repo>
|
||||
|
||||
|
||||
Clone a repository:
|
||||
|
||||
git = require 'gift'
|
||||
|
||||
git.clone "git@host:path/to/remote/repo.git", "path/to/local/clone/repo", (err, _repo) ->
|
||||
repo = _repo
|
||||
# => #<Repo>
|
||||
|
||||
## Repo
|
||||
### `Repo#path`
|
||||
`String` - The path to the repository.
|
||||
|
@ -18,3 +18,15 @@ Git.init = (path, callback) ->
|
||||
, (err, stdout, stderr) ->
|
||||
return callback err if err
|
||||
return callback err, (new Repo path)
|
||||
|
||||
# Public: Clone a git repository.
|
||||
#
|
||||
# repository - The repository to clone from.
|
||||
# path - The directory to clone into.
|
||||
# callback - Receives `(err, repo)`.
|
||||
#
|
||||
Git.clone = (repository, path, callback) ->
|
||||
bash = "git clone #{repository} #{path}"
|
||||
exec bash, (err, stdout, stderr) ->
|
||||
return callback err if err
|
||||
return callback err, (new Repo path)
|
@ -1,6 +1,7 @@
|
||||
should = require 'should'
|
||||
git = require '../src'
|
||||
Repo = require '../src/repo'
|
||||
{exec} = require 'child_process'
|
||||
|
||||
describe "git", ->
|
||||
describe "()", ->
|
||||
@ -8,3 +9,19 @@ describe "git", ->
|
||||
|
||||
it "returns a Repo", ->
|
||||
repo.should.be.an.instanceof Repo
|
||||
|
||||
describe "clone()", ->
|
||||
@timeout 30000
|
||||
repo = null
|
||||
newRepositoryDir = "#{__dirname}/fixtures/clone"
|
||||
before (done) ->
|
||||
git.clone "git@github.com:sentientwaffle/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
|
Loading…
Reference in New Issue
Block a user