better structure

This commit is contained in:
Peter Cottle 2012-11-03 14:45:26 -07:00
parent 4e9e48ab4b
commit d485120f44

View file

@ -48,6 +48,7 @@ GitEngine.prototype.init = function() {
GitEngine.prototype.exportTree = function() {
// need to export all commits, their connectivity / messages, branches, and state of head.
// this would be simple if didn't have circular structures.... :P
// thus, we need to loop through and "flatten" our graph of objects referencing one another
var totalExport = {
branches: {},
commits: {},
@ -62,8 +63,10 @@ GitEngine.prototype.exportTree = function() {
});
_.each(this.commitCollection.toJSON(), function(commit) {
commit.visNode = undefined;
commit.children = [];
// clear out the fields that reference objects and create circular structure
_.each(Commit.prototype.constants.circularFields, function(field) {
commit[field] = undefined;
}, this);
// convert parents
var parents = [];
@ -1450,6 +1453,10 @@ var Commit = Backbone.Model.extend({
gitVisuals: null
},
constants: {
circularFields: ['gitVisuals', 'visNode', 'children']
},
getLogEntry: function() {
// for now we are just joining all these things with newlines which
// will get placed by paragraph tags. Not really a fan of this, but