mirror of
https://github.com/danog/gift.git
synced 2024-11-26 20:04:47 +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
|
||||
|
||||
@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
|
||||
|
||||
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
|
||||
|
||||
[m, branch] = ref
|
||||
fs.readFile "#{repo.dot_git}/refs/heads/#{branch}", (err, id) ->
|
||||
Commit.find repo, id, (err, commit) ->
|
||||
fs.readFile "#{repo.dot_git}/refs/heads/#{branch}", "utf8", (err, id) ->
|
||||
Commit.find repo, id.trim(), (err, commit) ->
|
||||
return callback err if err
|
||||
return callback null, (new Head branch, commit)
|
||||
|
@ -1,7 +1,7 @@
|
||||
should = require 'should'
|
||||
git = require '../src'
|
||||
Repo = require '../src/repo'
|
||||
fs = require "fs"
|
||||
fs = require "fs-extra"
|
||||
exec = require 'flex-exec'
|
||||
|
||||
describe "git", ->
|
||||
@ -23,7 +23,7 @@ describe "git", ->
|
||||
bare = repo.bare || false
|
||||
bare.should.be.false
|
||||
after (done) ->
|
||||
exec "rm -rf #{newRepositoryDir}", done
|
||||
fs.remove newRepositoryDir, done
|
||||
|
||||
describe "init() bare", ->
|
||||
repo = null
|
||||
@ -38,7 +38,7 @@ describe "git", ->
|
||||
bare = repo.bare || false
|
||||
bare.should.be.true
|
||||
after (done) ->
|
||||
exec "rm -rf #{newRepositoryDir}", done
|
||||
fs.remove newRepositoryDir, done
|
||||
|
||||
describe "clone()", ->
|
||||
@timeout 30000
|
||||
@ -54,7 +54,7 @@ describe "git", ->
|
||||
remotes.should.have.length 1
|
||||
done()
|
||||
after (done) ->
|
||||
exec "rm -rf #{newRepositoryDir}", done
|
||||
fs.remove newRepositoryDir, done
|
||||
|
||||
describe "clone() with depth", ->
|
||||
@timeout 30000
|
||||
@ -70,7 +70,7 @@ describe "git", ->
|
||||
remotes.should.have.length 1
|
||||
done()
|
||||
after (done) ->
|
||||
exec "rm -rf #{newRepositoryDir}", done
|
||||
fs.remove newRepositoryDir, done
|
||||
|
||||
describe "clone() with depth and branch", ->
|
||||
@timeout 30000
|
||||
@ -85,4 +85,4 @@ describe "git", ->
|
||||
repo.branch "develop", (err, head) ->
|
||||
done err
|
||||
after (done) ->
|
||||
exec "rm -rf #{newRepositoryDir}", done
|
||||
fs.remove newRepositoryDir, done
|
||||
|
Loading…
Reference in New Issue
Block a user