diff --git a/spec/app/status-bar-spec.coffee b/spec/app/status-bar-spec.coffee index 9027afd36..b194c360f 100644 --- a/spec/app/status-bar-spec.coffee +++ b/spec/app/status-bar-spec.coffee @@ -102,3 +102,19 @@ describe "StatusBar", -> it "updates the cursor position in the status bar", -> editor.setCursorScreenPosition([1, 2]) expect(statusBar.cursorPosition.text()).toBe '2,3' + + describe "branch label", -> + beforeEach -> + rootView.attachToDom() + + it "displays the current branch for files in repositories", -> + path = require.resolve('fixtures/git/master.git/HEAD') + rootView.open(path) + expect(statusBar.branchArea).toBeVisible() + expect(statusBar.branchLabel.text()).toBe 'master' + + it "doesn't display the current branch for a file not in a repository", -> + path = require.resolve('fixtures/git/nohead.git/HEAD') + rootView.open(path) + expect(statusBar.branchArea).toBeHidden() + expect(statusBar.branchLabel.text()).toBe '' diff --git a/src/app/status-bar.coffee b/src/app/status-bar.coffee index f815da40f..3561460da 100644 --- a/src/app/status-bar.coffee +++ b/src/app/status-bar.coffee @@ -60,10 +60,10 @@ class StatusBar extends View if path = @editor.getPath() @head = new Git(path).getShortHead() else - @head = null + @head = '' + @branchLabel.text(@head) if @head - @branchLabel.text(@head) @branchArea.show() else @branchArea.hide()