mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Hide status and branch info for non-project files
This commit is contained in:
@@ -118,13 +118,24 @@ class Project
|
||||
|
||||
# Given a path, this makes it relative to the project directory.
|
||||
#
|
||||
# filePath - The {String} name of the path to convert
|
||||
# fullPath - The {String} path to convert.
|
||||
#
|
||||
# Returns a {String}.
|
||||
relativize: (fullPath) ->
|
||||
return fullPath unless fullPath.lastIndexOf(@getPath()) is 0
|
||||
fullPath.replace(@getPath(), "").replace(/^\//, '')
|
||||
|
||||
# Is the given path inside this project?
|
||||
#
|
||||
# pathToCheck - the {String} path to check.
|
||||
#
|
||||
# Returns a {Boolean}.
|
||||
contains: (pathToCheck) ->
|
||||
if pathToCheck
|
||||
if projectPath = @getPath()
|
||||
return pathToCheck.indexOf(path.join(projectPath, path.sep)) is 0
|
||||
false
|
||||
|
||||
# Identifies if the project is using soft tabs.
|
||||
#
|
||||
# Returns a {Boolean}.
|
||||
|
||||
@@ -84,18 +84,17 @@ class StatusBarView extends View
|
||||
@isModified = false
|
||||
|
||||
updateBranchText: ->
|
||||
path = @getActiveItemPath()
|
||||
@branchArea.hide()
|
||||
return unless path
|
||||
return unless project.contains(@getActiveItemPath())
|
||||
|
||||
head = git?.getShortHead() or ''
|
||||
@branchLabel.text(head)
|
||||
@branchArea.show() if head
|
||||
|
||||
updateStatusText: ->
|
||||
path = @getActiveItemPath()
|
||||
itemPath = @getActiveItemPath()
|
||||
@gitStatusIcon.removeClass()
|
||||
return unless path
|
||||
return unless project.contains(itemPath)
|
||||
|
||||
@gitStatusIcon.addClass('git-status octicons')
|
||||
return unless git?
|
||||
@@ -110,10 +109,10 @@ class StatusBarView extends View
|
||||
else
|
||||
@commitsBehind.hide()
|
||||
|
||||
status = git.statuses[path]
|
||||
status = git.statuses[itemPath]
|
||||
if git.isStatusModified(status)
|
||||
@gitStatusIcon.addClass('modified-status-icon')
|
||||
stats = git.getDiffStats(path)
|
||||
stats = git.getDiffStats(itemPath)
|
||||
if stats.added and stats.deleted
|
||||
@gitStatusIcon.text("+#{stats.added},-#{stats.deleted}")
|
||||
else if stats.added
|
||||
@@ -128,7 +127,7 @@ class StatusBarView extends View
|
||||
@gitStatusIcon.text("+#{@buffer.getLineCount()}")
|
||||
else
|
||||
@gitStatusIcon.text('')
|
||||
else if git.isPathIgnored(path)
|
||||
else if git.isPathIgnored(itemPath)
|
||||
@gitStatusIcon.addClass('ignored-status-icon')
|
||||
@gitStatusIcon.text('')
|
||||
|
||||
|
||||
@@ -124,7 +124,10 @@ describe "StatusBar", ->
|
||||
project.setPath('/tmp')
|
||||
rootView.open('/tmp/temp.txt')
|
||||
expect(statusBar.branchArea).toBeHidden()
|
||||
expect(statusBar.branchLabel.text()).toBe ''
|
||||
|
||||
it "doesn't display the current branch for a file outside the current project", ->
|
||||
rootView.open('/tmp/atom-specs/not-in-project.txt')
|
||||
expect(statusBar.branchArea).toBeHidden()
|
||||
|
||||
describe "git status label", ->
|
||||
[repo, filePath, originalPathText, newPath, ignoredPath] = []
|
||||
@@ -182,6 +185,10 @@ describe "StatusBar", ->
|
||||
rootView.open(newPath)
|
||||
expect(statusBar.gitStatusIcon).toHaveText('+1')
|
||||
|
||||
it "does not display for files not in the current project", ->
|
||||
rootView.open('/tmp/atom-specs/not-in-project.txt')
|
||||
expect(statusBar.gitStatusIcon).toBeHidden()
|
||||
|
||||
describe "grammar label", ->
|
||||
beforeEach ->
|
||||
atom.activatePackage('text-tmbundle', sync: true)
|
||||
|
||||
Reference in New Issue
Block a user