From 0bd0c9424b2110c923de388172c2316696f3f1af Mon Sep 17 00:00:00 2001 From: nielsAD Date: Tue, 25 Aug 2015 19:18:41 +0200 Subject: [PATCH 1/2] :bug: Use Git.isPathIgnored also when path does not match repo root Fixes #120 --- lib/load-paths-handler.coffee | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/load-paths-handler.coffee b/lib/load-paths-handler.coffee index 55d5f575..9401541e 100644 --- a/lib/load-paths-handler.coffee +++ b/lib/load-paths-handler.coffee @@ -11,10 +11,7 @@ class PathLoader 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' + @repo = if ignoreVcsIgnores then GitRepository.open(@rootPath, refreshOnWindowFocus: false) else null load: (done) -> @loadPath @rootPath, => @@ -23,10 +20,10 @@ class PathLoader done() isIgnored: (loadedPath) -> - relativePath = path.relative(@rootPath, loadedPath) - if @repo?.isPathIgnored(relativePath) + if @repo?.isPathIgnored(loadedPath) true else + relativePath = path.relative(@rootPath, loadedPath) for ignoredName in @ignoredNames return true if ignoredName.match(relativePath) From 2d60ccf38c9446fca3b0e3c50e8e96b458f768f9 Mon Sep 17 00:00:00 2001 From: nielsAD Date: Wed, 26 Aug 2015 13:47:24 +0200 Subject: [PATCH 2/2] :green_heart: Test for .gitignore exclude when working dir is subfolder --- spec/fuzzy-finder-spec.coffee | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/spec/fuzzy-finder-spec.coffee b/spec/fuzzy-finder-spec.coffee index 365cd081..70fa218b 100644 --- a/spec/fuzzy-finder-spec.coffee +++ b/spec/fuzzy-finder-spec.coffee @@ -923,15 +923,17 @@ describe 'FuzzyFinder', -> expect(bufferView.find('.status.status-added').closest('li').find('.file').text()).toBe 'newsample.js' describe "when core.excludeVcsIgnoredPaths is set to true", -> + [ignoreFile] = [] + beforeEach -> atom.config.set("core.excludeVcsIgnoredPaths", true) + ignoreFile = path.join(projectPath, '.gitignore') describe "when the project's path is the repository's working directory", -> beforeEach -> - ignoreFile = path.join(projectPath, '.gitignore') - fs.writeFileSync(ignoreFile, 'ignored.txt') - ignoredFile = path.join(projectPath, 'ignored.txt') + + fs.writeFileSync(ignoreFile, 'ignored.txt') fs.writeFileSync(ignoredFile, 'ignored text') it "excludes paths that are git ignored", -> @@ -945,22 +947,25 @@ describe 'FuzzyFinder', -> describe "when the project's path is a subfolder of the repository's working directory", -> beforeEach -> - atom.project.setPaths([gitDirectory.resolve('dir')]) - ignoreFile = path.join(projectPath, '.gitignore') - fs.writeFileSync(ignoreFile, 'b.txt') + dirPath = gitDirectory.resolve('dir') + atom.project.setPaths([dirPath]) + + ignoredFile = path.join(dirPath, 'ignored.txt') - it "does not exclude paths that are git ignored", -> + fs.writeFileSync(ignoreFile, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'ignored text') + + it "excludes paths that are git ignored", -> dispatchCommand('toggle-file-finder') projectView.setMaxItems(Infinity) waitForPathsToDisplay(projectView) runs -> - expect(projectView.list.find("li:contains(b.txt)")).toExist() + expect(projectView.list.find("li:contains(ignored.txt)")).not.toExist() describe "when the .gitignore matches parts of the path to the root folder", -> beforeEach -> - ignoreFile = path.join(projectPath, '.gitignore') fs.writeFileSync(ignoreFile, path.basename(projectPath)) it "only applies the .gitignore patterns to relative paths within the root folder", ->