Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/load-paths-handler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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, =>
Expand All @@ -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)

Expand Down
23 changes: 14 additions & 9 deletions spec/fuzzy-finder-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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", ->
Expand All @@ -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", ->
Expand Down