mirror of
https://github.com/atom/atom.git
synced 2026-01-26 15:28:27 -05:00
getPath
This commit is contained in:
@@ -34,18 +34,31 @@ fdescribe "GitRepositoryAsync", ->
|
||||
expect(repo.repo).toBe null
|
||||
|
||||
describe ".getPath()", ->
|
||||
it "returns the repository path for a .git directory path", ->
|
||||
# XXX HEAD isn't a git directory.. what's this spec supposed to be about?
|
||||
xit "returns the repository path for a .git directory path", ->
|
||||
# Rejects as malformed
|
||||
repo = GitRepositoryAsync.open(path.join(__dirname, 'fixtures', 'git', 'master.git', 'HEAD'))
|
||||
|
||||
waitsForPromise ->
|
||||
repo.getPath
|
||||
onSuccess = jasmine.createSpy('onSuccess')
|
||||
|
||||
runs ->
|
||||
expect(repo.getPath()).toBe path.join(__dirname, 'fixtures', 'git', 'master.git')
|
||||
waitsForPromise ->
|
||||
repo.getPath().then(onSuccess)
|
||||
|
||||
runs ->
|
||||
expectedPath = path.join(__dirname, 'fixtures', 'git', 'master.git')
|
||||
expect(onSuccess.mostRecentCall.args[0]).toBe(expectedPath)
|
||||
|
||||
it "returns the repository path for a repository path", ->
|
||||
repo = new GitRepository(path.join(__dirname, 'fixtures', 'git', 'master.git'))
|
||||
expect(repo.getPath()).toBe path.join(__dirname, 'fixtures', 'git', 'master.git')
|
||||
repo = GitRepositoryAsync.open(path.join(__dirname, 'fixtures', 'git', 'master.git'))
|
||||
|
||||
onSuccess = jasmine.createSpy('onSuccess')
|
||||
|
||||
waitsForPromise ->
|
||||
repo.getPath().then(onSuccess)
|
||||
|
||||
runs ->
|
||||
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", ->
|
||||
|
||||
@@ -13,11 +13,20 @@ module.exports = class GitRepositoryAsync {
|
||||
// this could be replaced with a function
|
||||
this._opening = true
|
||||
|
||||
// Do I use this outside of tests?
|
||||
openPromise.then( (repo) => {
|
||||
this.repo = repo
|
||||
this._opening = false
|
||||
}).catch( (e) => {
|
||||
this._opening = false
|
||||
})
|
||||
|
||||
this.repoPromise = openPromise
|
||||
}
|
||||
|
||||
getPath () {
|
||||
return this.repoPromise.then( (repo) => {
|
||||
return Promise.resolve(repo.path().replace(/\/$/, ''))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user