Merge "Add undefined check to revision-info"

This commit is contained in:
Ben Rohlfs
2019-08-05 12:57:35 +00:00
committed by Gerrit Code Review

View File

@@ -35,6 +35,9 @@ limitations under the License.
* @return {Number} * @return {Number}
*/ */
RevisionInfo.prototype.getMaxParents = function() { RevisionInfo.prototype.getMaxParents = function() {
if (!this._change || !this._change.revisions) {
return 0;
}
return Object.values(this._change.revisions) return Object.values(this._change.revisions)
.reduce((acc, rev) => Math.max(rev.commit.parents.length, acc), 0); .reduce((acc, rev) => Math.max(rev.commit.parents.length, acc), 0);
}; };
@@ -46,6 +49,9 @@ limitations under the License.
*/ */
RevisionInfo.prototype.getParentCountMap = function() { RevisionInfo.prototype.getParentCountMap = function() {
const result = {}; const result = {};
if (!this._change || !this._change.revisions) {
return {};
}
Object.values(this._change.revisions) Object.values(this._change.revisions)
.forEach(rev => { result[rev._number] = rev.commit.parents.length; }); .forEach(rev => { result[rev._number] = rev.commit.parents.length; });
return result; return result;