Add getParent method for Commit objects

Add method to retrieve a given parent (not ancestor) of a commit object.
If the commit doesn't have the requested parent return null.
This commit is contained in:
Aaron Schrab 2013-02-20 17:54:23 -05:00
parent e94710ca64
commit 4928e71a4b

View file

@ -1685,6 +1685,13 @@ var Commit = Backbone.Model.extend({
this.get('gitVisuals').addEdge(this.get('id'), parent.get('id'));
},
getParent: function(parentNum) {
if (this && this.attributes && this.attributes.parents)
return this.attributes.parents[parentNum];
else
return null;
},
isMainParent: function(parent) {
var index = this.get('parents').indexOf(parent);
return index === 0;