From 565f28dfc47203dd5bcbf7a59083b85f1f1c0086 Mon Sep 17 00:00:00 2001 From: joshaber Date: Thu, 7 Jan 2016 16:36:55 -0500 Subject: [PATCH] Update . getCachedUpstreamAheadBehindCount() Take submodules into account. --- src/git-repository-async.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/git-repository-async.js b/src/git-repository-async.js index 947742a5d..060bb7133 100644 --- a/src/git-repository-async.js +++ b/src/git-repository-async.js @@ -290,12 +290,19 @@ 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 an {Object} with the following keys: + // Returns a {Promise} which resolves to an {Object} with the following keys: // * `ahead` The {Number} of commits ahead. // * `behind` The {Number} of commits behind. getCachedUpstreamAheadBehindCount (_path) { - // TODO: take submodules into account - return this.upstream + return this.relativizeToWorkingDirectory(_path) + .then(relativePath => this._submoduleForPath(_path)) + .then(submodule => { + if (submodule) { + return submodule.getCachedUpstreamAheadBehindCount(_path) + } else { + return this.upstream + } + }) } // Public: Returns the git configuration value specified by the key.