mirror of
https://github.com/atom/atom.git
synced 2026-01-27 07:47:58 -05:00
isPathIgnored
This commit is contained in:
@@ -11,6 +11,9 @@ copyRepository = ->
|
||||
fs.renameSync(path.join(workingDirPath, 'git.git'), path.join(workingDirPath, '.git'))
|
||||
workingDirPath
|
||||
|
||||
openFixture = (fixture)->
|
||||
GitRepositoryAsync.open(path.join(__dirname, 'fixtures', 'git', fixture))
|
||||
|
||||
fdescribe "GitRepositoryAsync", ->
|
||||
repo = null
|
||||
|
||||
@@ -49,7 +52,7 @@ fdescribe "GitRepositoryAsync", ->
|
||||
expect(onSuccess.mostRecentCall.args[0]).toBe(expectedPath)
|
||||
|
||||
it "returns the repository path for a repository path", ->
|
||||
repo = GitRepositoryAsync.open(path.join(__dirname, 'fixtures', 'git', 'master.git'))
|
||||
repo = openFixture('master.git')
|
||||
|
||||
onSuccess = jasmine.createSpy('onSuccess')
|
||||
|
||||
@@ -60,14 +63,24 @@ fdescribe "GitRepositoryAsync", ->
|
||||
expectedPath = path.join(__dirname, 'fixtures', 'git', 'master.git')
|
||||
expect(onSuccess.mostRecentCall.args[0]).toBe(expectedPath)
|
||||
|
||||
xdescribe ".isPathIgnored(path)", ->
|
||||
it "returns true for an ignored path", ->
|
||||
repo = new GitRepository(path.join(__dirname, 'fixtures', 'git', 'ignore.git'))
|
||||
expect(repo.isPathIgnored('a.txt')).toBeTruthy()
|
||||
describe ".isPathIgnored(path)", ->
|
||||
it "resolves true for an ignored path", ->
|
||||
repo = openFixture('ignore.git')
|
||||
onSuccess = jasmine.createSpy('onSuccess')
|
||||
waitsForPromise ->
|
||||
repo.isPathIgnored('a.txt').then(onSuccess).catch (e) -> console.log e
|
||||
|
||||
runs ->
|
||||
expect(onSuccess.mostRecentCall.args[0]).toBeTruthy()
|
||||
|
||||
it "resolves false for a non-ignored path", ->
|
||||
repo = openFixture('ignore.git')
|
||||
onSuccess = jasmine.createSpy('onSuccess')
|
||||
waitsForPromise ->
|
||||
repo.isPathIgnored('b.txt').then(onSuccess)
|
||||
runs ->
|
||||
expect(onSuccess.mostRecentCall.args[0]).toBeFalsy()
|
||||
|
||||
it "returns false for a non-ignored path", ->
|
||||
repo = new GitRepository(path.join(__dirname, 'fixtures', 'git', 'ignore.git'))
|
||||
expect(repo.isPathIgnored('b.txt')).toBeFalsy()
|
||||
|
||||
xdescribe ".isPathModified(path)", ->
|
||||
[repo, filePath, newPath] = []
|
||||
|
||||
@@ -29,4 +29,10 @@ module.exports = class GitRepositoryAsync {
|
||||
return Promise.resolve(repo.path().replace(/\/$/, ''))
|
||||
})
|
||||
}
|
||||
|
||||
isPathIgnored(_path) {
|
||||
return this.repoPromise.then( (repo) => {
|
||||
return Promise.resolve(Git.Ignore.pathIsIgnored(repo, _path))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user