Abbreviate SHA-1s when HEAD is detached

This commit is contained in:
Kevin Sawicki
2012-10-25 11:06:49 -07:00
committed by Corey Johnson
parent 8831c2a2dc
commit d66315dd21
2 changed files with 6 additions and 3 deletions

View File

@@ -9,8 +9,11 @@ class Git
@repo = new GitRepository(@repoPath)
getHead: ->
head = @repo.getHead()
return '' unless head
@repo.getHead() || ''
getShortHead: ->
head = @getHead()
return head.substring(11) if head.indexOf('refs/heads/') is 0
return head.substring(10) if head.indexOf('refs/tags/') is 0
return head.substring(13) if head.indexOf('refs/remotes/') is 0
return head.substring(0, 7) if head.match(/[a-fA-F0-9]{40}/)

View File

@@ -51,7 +51,7 @@ class StatusBar extends View
updatePathText: ->
path = @editor.getPath()
if path
@head = Git.open(path)?.getHead()
@head = Git.open(path)?.getShortHead()
@currentPath.text(@rootView.project.relativize(path))
else
@currentPath.text('untitled')