Merge pull request #10758 from atom/fix-status-in-subdir

Fix status in subdir
This commit is contained in:
Josh Abernathy 2016-02-10 15:15:10 -05:00 committed by joshaber
parent 69df5d0836
commit b7da70a7e9
3 changed files with 31 additions and 2 deletions

View File

@ -28,7 +28,7 @@
"fs-plus": "^2.8.0",
"fstream": "0.1.24",
"fuzzaldrin": "^2.1",
"git-utils": "^4.1.0",
"git-utils": "^4.1.2",
"grim": "1.5.0",
"jasmine-json": "~0.0",
"jasmine-tagged": "^1.1.4",

View File

@ -195,7 +195,7 @@ describe "GitRepository", ->
expect(repo.isStatusModified(repo.getDirectoryStatus(directoryPath))).toBe true
describe ".refreshStatus()", ->
[newPath, modifiedPath, cleanPath, originalModifiedPathText] = []
[newPath, modifiedPath, cleanPath, originalModifiedPathText, workingDirectory] = []
beforeEach ->
workingDirectory = copyRepository()
@ -221,6 +221,34 @@ describe "GitRepository", ->
expect(repo.isStatusNew(repo.getCachedPathStatus(newPath))).toBeTruthy()
expect(repo.isStatusModified(repo.getCachedPathStatus(modifiedPath))).toBeTruthy()
it 'caches the proper statuses when a subdir is open', ->
subDir = path.join(workingDirectory, 'dir')
fs.mkdirSync(subDir)
filePath = path.join(subDir, 'b.txt')
fs.writeFileSync(filePath, '')
atom.project.setPaths([subDir])
waitsForPromise ->
atom.workspace.open('b.txt')
statusHandler = null
runs ->
repo = atom.project.getRepositories()[0]
statusHandler = jasmine.createSpy('statusHandler')
repo.onDidChangeStatuses statusHandler
repo.refreshStatus()
waitsFor ->
statusHandler.callCount > 0
runs ->
status = repo.getCachedPathStatus(filePath)
expect(repo.isStatusModified(status)).toBe false
expect(repo.isStatusNew(status)).toBe false
describe "buffer events", ->
[editor] = []

View File

@ -466,6 +466,7 @@ class GitRepository
relativeProjectPaths = @project?.getPaths()
.map (path) => @relativize(path)
.filter (path) -> path.length > 0
.map (path) -> path + '/**'
@statusTask?.terminate()
@statusTask = Task.once @handlerPath, @getPath(), relativeProjectPaths, ({statuses, upstream, branch, submodules}) =>