Add .isSubmodule

This commit is contained in:
Daniel Hengeveld
2015-10-26 16:35:57 +01:00
parent 4a478f7f84
commit abd41d1208

View File

@@ -288,4 +288,21 @@ module.exports = class GitRepositoryAsync {
return this.projectAtRoot
}
// Returns a {Promise} that resolves true if the given path is a submodule in
// the repository.
isSubmodule (_path) {
return this.repoPromise.then(function (repo) {
return repo.openIndex()
}).then(function (index) {
let entry = index.getByPath(_path)
let submoduleMode = 57344 // TODO compose this from libgit2 constants
if (entry.mode === submoduleMode) {
return true
} else {
return false
}
})
}
}