mirror of
https://github.com/danog/gift.git
synced 2024-11-30 04:19:37 +01:00
Applied tweaks from #38
This commit is contained in:
parent
6649250e73
commit
1eb737244d
@ -38,7 +38,7 @@ exports.Head = class Head extends Ref
|
|||||||
Ref.find_all repo, "head", Head, callback
|
Ref.find_all repo, "head", Head, callback
|
||||||
|
|
||||||
@current: (repo, callback) ->
|
@current: (repo, callback) ->
|
||||||
fs.readFile "#{repo.dot_git}/HEAD", (err, data) ->
|
fs.readFile "#{repo.dot_git}/HEAD", "utf8", (err, data) ->
|
||||||
return callback err if err
|
return callback err if err
|
||||||
|
|
||||||
ref = /ref: refs\/heads\/([^\s]+)/.exec data
|
ref = /ref: refs\/heads\/([^\s]+)/.exec data
|
||||||
@ -46,7 +46,7 @@ exports.Head = class Head extends Ref
|
|||||||
return callback new Error "Current branch is not a valid branch." if !ref
|
return callback new Error "Current branch is not a valid branch." if !ref
|
||||||
|
|
||||||
[m, branch] = ref
|
[m, branch] = ref
|
||||||
fs.readFile "#{repo.dot_git}/refs/heads/#{branch}", (err, id) ->
|
fs.readFile "#{repo.dot_git}/refs/heads/#{branch}", "utf8", (err, id) ->
|
||||||
Commit.find repo, id, (err, commit) ->
|
Commit.find repo, id.trim(), (err, commit) ->
|
||||||
return callback err if err
|
return callback err if err
|
||||||
return callback null, (new Head branch, commit)
|
return callback null, (new Head branch, commit)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
should = require 'should'
|
should = require 'should'
|
||||||
git = require '../src'
|
git = require '../src'
|
||||||
Repo = require '../src/repo'
|
Repo = require '../src/repo'
|
||||||
fs = require "fs"
|
fs = require "fs-extra"
|
||||||
exec = require 'flex-exec'
|
exec = require 'flex-exec'
|
||||||
|
|
||||||
describe "git", ->
|
describe "git", ->
|
||||||
@ -23,7 +23,7 @@ describe "git", ->
|
|||||||
bare = repo.bare || false
|
bare = repo.bare || false
|
||||||
bare.should.be.false
|
bare.should.be.false
|
||||||
after (done) ->
|
after (done) ->
|
||||||
exec "rm -rf #{newRepositoryDir}", done
|
fs.remove newRepositoryDir, done
|
||||||
|
|
||||||
describe "init() bare", ->
|
describe "init() bare", ->
|
||||||
repo = null
|
repo = null
|
||||||
@ -38,7 +38,7 @@ describe "git", ->
|
|||||||
bare = repo.bare || false
|
bare = repo.bare || false
|
||||||
bare.should.be.true
|
bare.should.be.true
|
||||||
after (done) ->
|
after (done) ->
|
||||||
exec "rm -rf #{newRepositoryDir}", done
|
fs.remove newRepositoryDir, done
|
||||||
|
|
||||||
describe "clone()", ->
|
describe "clone()", ->
|
||||||
@timeout 30000
|
@timeout 30000
|
||||||
@ -54,7 +54,7 @@ describe "git", ->
|
|||||||
remotes.should.have.length 1
|
remotes.should.have.length 1
|
||||||
done()
|
done()
|
||||||
after (done) ->
|
after (done) ->
|
||||||
exec "rm -rf #{newRepositoryDir}", done
|
fs.remove newRepositoryDir, done
|
||||||
|
|
||||||
describe "clone() with depth", ->
|
describe "clone() with depth", ->
|
||||||
@timeout 30000
|
@timeout 30000
|
||||||
@ -70,7 +70,7 @@ describe "git", ->
|
|||||||
remotes.should.have.length 1
|
remotes.should.have.length 1
|
||||||
done()
|
done()
|
||||||
after (done) ->
|
after (done) ->
|
||||||
exec "rm -rf #{newRepositoryDir}", done
|
fs.remove newRepositoryDir, done
|
||||||
|
|
||||||
describe "clone() with depth and branch", ->
|
describe "clone() with depth and branch", ->
|
||||||
@timeout 30000
|
@timeout 30000
|
||||||
@ -85,4 +85,4 @@ describe "git", ->
|
|||||||
repo.branch "develop", (err, head) ->
|
repo.branch "develop", (err, head) ->
|
||||||
done err
|
done err
|
||||||
after (done) ->
|
after (done) ->
|
||||||
exec "rm -rf #{newRepositoryDir}", done
|
fs.remove newRepositoryDir, done
|
||||||
|
Loading…
Reference in New Issue
Block a user