From 8f9b6a30821f16a7acc74aaffd159f942c8dd387 Mon Sep 17 00:00:00 2001 From: Michael Bolin Date: Thu, 12 Feb 2015 20:10:30 -0800 Subject: [PATCH] Replace directoryExistsSync() with Directory::existsSync(). This makes it possible to remove a TODO in `GitRepositoryProvider`. --- src/git-repository-provider.coffee | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/git-repository-provider.coffee b/src/git-repository-provider.coffee index de8cd64d4..dd9c41f41 100644 --- a/src/git-repository-provider.coffee +++ b/src/git-repository-provider.coffee @@ -11,7 +11,7 @@ findGitDirectorySync = (directory) -> # can return cached values rather than always returning new objects: # getParent(), getFile(), getSubdirectory(). gitDir = directory.getSubdirectory('.git') - if directoryExistsSync(gitDir) and isValidGitDirectorySync gitDir + if gitDir.existsSync() and isValidGitDirectorySync gitDir gitDir else if directory.isRoot() return null @@ -26,19 +26,9 @@ isValidGitDirectorySync = (directory) -> # To decide whether a directory has a valid .git folder, we use # the heuristic adopted by the valid_repository_path() function defined in # node_modules/git-utils/deps/libgit2/src/repository.c. - return directoryExistsSync(directory.getSubdirectory('objects')) and + return directory.getSubdirectory('objects').existsSync() and directory.getFile('HEAD').existsSync() and - directoryExistsSync(directory.getSubdirectory('refs')) - -# Returns a boolean indicating whether the specified directory exists. -# -# * `directory` {Directory} to check for existence. -directoryExistsSync = (directory) -> - # TODO: Directory should have its own existsSync() method. Currently, File has - # an exists() method, which is synchronous, so it may be tricky to achieve - # consistency between the File and Directory APIs. Once Directory has its own - # method, this function should be replaced with direct calls to existsSync(). - return fs.existsSync(directory.getPath()) + directory.getSubdirectory('refs').existsSync() # Provider that conforms to the atom.repository-provider@0.1.0 service. module.exports =