mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Abbreviate SHA-1s when HEAD is detached
This commit is contained in:
committed by
Corey Johnson
parent
8831c2a2dc
commit
d66315dd21
@@ -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}/)
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user