mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 18:24:09 +03:00
Merge pull request #5660 from atom/bf-git-repository-provider-should-not-throw
Make sure that GitRepositoryProvider.repositoryForDirectorySync() return...
This commit is contained in:
commit
0be34a892f
@ -54,3 +54,27 @@ describe "GitRepositoryProvider", ->
|
|||||||
directory = new Directory dirPath
|
directory = new Directory dirPath
|
||||||
provider.repositoryForDirectory(directory).then (result) ->
|
provider.repositoryForDirectory(directory).then (result) ->
|
||||||
expect(result).toBe null
|
expect(result).toBe null
|
||||||
|
|
||||||
|
describe "when specified a Directory without existsSync()", ->
|
||||||
|
directory = null
|
||||||
|
provider = null
|
||||||
|
beforeEach ->
|
||||||
|
provider = new GitRepositoryProvider atom.project
|
||||||
|
|
||||||
|
# An implementation of Directory that does not implement existsSync().
|
||||||
|
subdirectory = {}
|
||||||
|
directory =
|
||||||
|
getSubdirectory: ->
|
||||||
|
isRoot: -> true
|
||||||
|
spyOn(directory, "getSubdirectory").andReturn(subdirectory)
|
||||||
|
|
||||||
|
it "returns null", ->
|
||||||
|
repo = provider.repositoryForDirectorySync(directory)
|
||||||
|
expect(repo).toBe null
|
||||||
|
expect(directory.getSubdirectory).toHaveBeenCalledWith(".git")
|
||||||
|
|
||||||
|
it "returns a Promise that resolves to null for the async implementation", ->
|
||||||
|
waitsForPromise ->
|
||||||
|
provider.repositoryForDirectory(directory).then (repo) ->
|
||||||
|
expect(repo).toBe null
|
||||||
|
expect(directory.getSubdirectory).toHaveBeenCalledWith(".git")
|
||||||
|
@ -11,7 +11,7 @@ findGitDirectorySync = (directory) ->
|
|||||||
# can return cached values rather than always returning new objects:
|
# can return cached values rather than always returning new objects:
|
||||||
# getParent(), getFile(), getSubdirectory().
|
# getParent(), getFile(), getSubdirectory().
|
||||||
gitDir = directory.getSubdirectory('.git')
|
gitDir = directory.getSubdirectory('.git')
|
||||||
if gitDir.existsSync() and isValidGitDirectorySync gitDir
|
if gitDir.existsSync?() and isValidGitDirectorySync gitDir
|
||||||
gitDir
|
gitDir
|
||||||
else if directory.isRoot()
|
else if directory.isRoot()
|
||||||
return null
|
return null
|
||||||
|
Loading…
Reference in New Issue
Block a user