mirror of
https://github.com/danog/gift.git
synced 2024-11-30 04:19:37 +01:00
Pass options to git checkout
This commit is contained in:
parent
9ab85611f1
commit
d6ed167156
@ -365,8 +365,13 @@ module.exports = class Repo
|
||||
|
||||
|
||||
# Public: Checkout the treeish.
|
||||
checkout: (treeish, callback) ->
|
||||
@git "checkout", {}, treeish, callback
|
||||
#
|
||||
# options - The {Object} containing any of the options available to git checkout:
|
||||
# :b - {Boolean) Creates a branch when it doesn't exist yet.
|
||||
#
|
||||
checkout: (treeish, options, callback) ->
|
||||
[options, callback] = [{}, options] if !callback
|
||||
@git "checkout", options, treeish, callback
|
||||
|
||||
# Public: Clean the git repo by removing untracked files
|
||||
#
|
||||
|
@ -676,6 +676,37 @@ describe "Repo", ->
|
||||
status.files.should.not.have.a.property file
|
||||
status.files.should.not.have.a.property 'rawr.txt'
|
||||
|
||||
describe "#checkout", ->
|
||||
repo = null
|
||||
head = null
|
||||
git_dir = __dirname + "/fixtures/junk_checkout"
|
||||
|
||||
# given a fresh new repo
|
||||
beforeEach (done) ->
|
||||
fs.remove git_dir, (err) ->
|
||||
return done err if err
|
||||
fs.copy "#{__dirname}/fixtures/reset", "#{git_dir}", (err) ->
|
||||
return done err if err
|
||||
fs.rename "#{git_dir}/git.git", "#{git_dir}/.git", (err) ->
|
||||
git.init git_dir, (err) ->
|
||||
return done err if err
|
||||
repo = git git_dir
|
||||
done()
|
||||
|
||||
after (done) ->
|
||||
fs.remove git_dir, (err) ->
|
||||
done err
|
||||
|
||||
describe "and create new branch", ->
|
||||
beforeEach (done) ->
|
||||
repo.checkout "feature/foo", {b: true}, ->
|
||||
repo.branch (err, _head) ->
|
||||
head = _head
|
||||
done err
|
||||
|
||||
it "should succeed", ->
|
||||
head.name.should.equal "feature/foo"
|
||||
|
||||
describe "#checkoutFile", ->
|
||||
repo = null
|
||||
git_dir = __dirname + "/fixtures/junk_checkoutFile"
|
||||
|
Loading…
Reference in New Issue
Block a user