diff --git a/lib/load-paths-handler.coffee b/lib/load-paths-handler.coffee index 3a67eeb9..731790fa 100644 --- a/lib/load-paths-handler.coffee +++ b/lib/load-paths-handler.coffee @@ -4,33 +4,45 @@ path = require 'path' _ = require 'underscore-plus' {GitRepository} = require 'atom' {Minimatch} = require 'minimatch' +{GitProcess} = require 'dugite' PathsChunkSize = 100 emittedPaths = new Set class PathLoader - constructor: (@rootPath, ignoreVcsIgnores, @traverseSymlinkDirectories, @ignoredNames) -> + constructor: (@rootPath, @ignoreVcsIgnores, @traverseSymlinkDirectories, @ignoredNames) -> @paths = [] @realPathCache = {} - @repo = null - if ignoreVcsIgnores - repo = GitRepository.open(@rootPath, refreshOnWindowFocus: false) - @repo = repo if repo?.relativize(path.join(@rootPath, 'test')) is 'test' load: (done) -> - @loadPath @rootPath, true, => - @flushPaths() - @repo?.destroy() - done() + repo = GitRepository.open(@rootPath, refreshOnWindowFocus: false) + if repo?.relativize(path.join(@rootPath, 'test')) is 'test' + args = ['ls-files', '--cached', '--others', '-z'] + if @ignoreVcsIgnores + args.push('--exclude-standard') + for ignoredName in @ignoredNames + args.push('--exclude') + args.push(ignoredName.pattern) + output = '' + proc = GitProcess.spawn(args, @rootPath) + proc.stdout.on 'data', (chunk) -> + files = (output + chunk).split('\0') + output = files.pop() + emit('load-paths:paths-found', files) + proc.on 'close', (code) -> + repo?.destroy() + done() + else + @loadPath @rootPath, true, => + @flushPaths() + repo?.destroy() + done() isIgnored: (loadedPath) -> relativePath = path.relative(@rootPath, loadedPath) - if @repo?.isPathIgnored(relativePath) - true - else - for ignoredName in @ignoredNames - return true if ignoredName.match(relativePath) + for ignoredName in @ignoredNames + return true if ignoredName.match(relativePath) pathLoaded: (loadedPath, done) -> unless @isIgnored(loadedPath) or emittedPaths.has(loadedPath) diff --git a/package.json b/package.json index aaf1c1bf..ebf09fd9 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dependencies": { "async": "0.2.6", "atom-select-list": "^0.1.0", + "dugite": "^1.35.0", "fs-plus": "^3.0.0", "fuzzaldrin": "^2.0", "fuzzaldrin-plus": "^0.4.1",