Skip to content

Commit

Permalink
Applied tweaks from #38
Browse files Browse the repository at this point in the history
  • Loading branch information
notatestuser committed Jan 22, 2018
1 parent 6649250 commit 1eb7372
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/ref.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ 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
# When the current branch check out to a commit, instaed of a branch name.
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)
12 changes: 6 additions & 6 deletions test/index.test.coffee
Original file line number Diff line number Diff line change
@@ -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", ->
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -85,4 +85,4 @@ describe "git", ->
repo.branch "develop", (err, head) ->
done err
after (done) ->
exec "rm -rf #{newRepositoryDir}", done
fs.remove newRepositoryDir, done

0 comments on commit 1eb7372

Please sign in to comment.