Skip to content

Commit

Permalink
Fix test: return error when the current branch check out to a commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaoshing committed Jul 7, 2014
1 parent 16842b8 commit d85f686
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ref.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ exports.Head = class Head extends Ref
@current: (repo, callback) ->
fs.readFile "#{repo.dot_git}/HEAD", (err, data) ->
return callback err if err
[m, branch] = /ref: refs\/heads\/([^\s]+)/.exec data

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) ->
return callback err if err
Expand Down

0 comments on commit d85f686

Please sign in to comment.