add .async attribute to GitRepository

This commit is contained in:
Daniel Hengeveld 2015-10-20 13:59:58 +02:00
parent 0e6d30e707
commit 60180677a2
2 changed files with 13 additions and 0 deletions

View File

@ -25,6 +25,16 @@ describe "GitRepository", ->
it "returns null when no repository is found", ->
expect(GitRepository.open(path.join(temp.dir, 'nogit.txt'))).toBeNull()
describe ".async", ->
it "returns a GitRepositoryAsync for the same repo", ->
repoPath = path.join(__dirname, 'fixtures', 'git', 'master.git')
repo = new GitRepository(repoPath)
onSuccess = jasmine.createSpy('onSuccess')
waitsForPromise ->
repo.async.getPath().then(onSuccess)
runs ->
expect(onSuccess.mostRecentCall.args[0]).toBe(repoPath)
describe "new GitRepository(path)", ->
it "throws an exception when no repository is found", ->
expect(-> new GitRepository(path.join(temp.dir, 'nogit.txt'))).toThrow()

View File

@ -3,6 +3,7 @@
_ = require 'underscore-plus'
{Emitter, Disposable, CompositeDisposable} = require 'event-kit'
fs = require 'fs-plus'
GitRepositoryAsync = require './git-repository-async'
GitUtils = require 'git-utils'
Task = require './task'
@ -75,6 +76,8 @@ class GitRepository
unless @repo?
throw new Error("No Git repository found searching path: #{path}")
@async = GitRepositoryAsync.open(path)
@statuses = {}
@upstream = {ahead: 0, behind: 0}
for submodulePath, submoduleRepo of @repo.submodules