Added .getConfigValue

This commit is contained in:
joshaber
2015-12-03 12:18:00 -05:00
parent 70601772d0
commit 74a0528bef
2 changed files with 27 additions and 5 deletions

View File

@@ -472,9 +472,8 @@ describe('GitRepositoryAsync', () => {
})
describe('.getReferences(path)', () => {
let workingDirectory
beforeEach(() => {
workingDirectory = copyRepository()
const workingDirectory = copyRepository()
repo = GitRepositoryAsync.open(workingDirectory)
})
@@ -487,9 +486,8 @@ describe('GitRepositoryAsync', () => {
})
describe('.getReferenceTarget(reference, path)', () => {
let workingDirectory
beforeEach(() => {
workingDirectory = copyRepository()
const workingDirectory = copyRepository()
repo = GitRepositoryAsync.open(workingDirectory)
})
@@ -498,4 +496,22 @@ describe('GitRepositoryAsync', () => {
expect(SHA).toBe('8a9c86f1cb1f14b8f436eb91f4b052c8802ca99e')
})
})
describe('.getConfigValue(key, path)', () => {
beforeEach(() => {
const workingDirectory = copyRepository()
console.log(workingDirectory)
repo = GitRepositoryAsync.open(workingDirectory)
})
it('looks up the value for the key', async () => {
const bare = await repo.getConfigValue('core.bare')
expect(bare).toBe('false')
})
it("resolves to null if there's no value", async () => {
const value = await repo.getConfigValue('my.special.key')
expect(value).toBe(null)
})
})
})

View File

@@ -233,8 +233,14 @@ export default class GitRepositoryAsync {
//
// * `path` An optional {String} path in the repository to get this information
// for, only needed if the repository has submodules.
//
// Returns a {Promise} which resolves to the {String} git configuration value
// specified by the key.
getConfigValue (key, _path) {
throw new Error('Unimplemented')
return this._getRepo(_path)
.then(repo => repo.configSnapshot())
.then(config => config.getStringBuf(key))
.catch(_ => null)
}
// Public: Returns the origin url of the repository.