Test .isSubmodule.

This commit is contained in:
joshaber 2016-01-07 16:48:28 -05:00
parent d2d5966ee1
commit 92839a1f4f
2 changed files with 17 additions and 4 deletions

View File

@ -568,6 +568,23 @@ describe('GitRepositoryAsync', () => {
})
})
describe('.isSubmodule(path)', () => {
beforeEach(() => {
const workingDirectory = copySubmoduleRepository()
repo = GitRepositoryAsync.open(workingDirectory)
})
it("returns false for a path that isn't a submodule", async () => {
const isSubmodule = await repo.isSubmodule('README')
expect(isSubmodule).toBe(false)
})
it('returns true for a path that is a submodule', async () => {
const isSubmodule = await repo.isSubmodule('jstips')
expect(isSubmodule).toBe(true)
})
})
describe('.getAheadBehindCount(reference, path)', () => {
beforeEach(() => {
const workingDirectory = copyRepository()

View File

@ -252,8 +252,6 @@ export default class GitRepositoryAsync {
.then(repo => repo.openIndex())
.then(index => Promise.all([index, this.relativizeToWorkingDirectory(_path)]))
.then(([index, relativePath]) => {
// TODO: This'll probably be wrong if the submodule doesn't exist in the
// index yet? Is that a thing?
const entry = index.getByPath(relativePath)
if (!entry) return false
@ -894,8 +892,6 @@ export default class GitRepositoryAsync {
//
// Returns a {Promise} which will resolve to {null} when refresh is complete.
refreshStatus () {
// TODO add submodule tracking
const status = this._refreshStatus()
const branch = this._refreshBranch()
const aheadBehind = branch.then(branchName => this._refreshAheadBehindCount(branchName))