@@ -3,9 +3,10 @@ var git = require('../'),
33
44/**
55 * Convenience diff list class.
6- *
6+ *
7+ * @constructor
78 * @param {git.raw.Repo } rawRepo
8- * @param {[type] } rawDiffList [description]
9+ * @param {git.raw.DiffList } [ rawDiffList = new git.raw.DiffList]
910 */
1011var DiffList = function ( rawRepo , rawDiffList ) {
1112 if ( ! ( rawRepo instanceof git . raw . Repo ) ) {
@@ -55,6 +56,14 @@ DiffList.prototype.lineOriginTypes = {
5556 /** 'B' */ GIT_DIFF_LINE_BINARY : git . raw . DiffList . lineOriginTypes . GIT_DIFF_LINE_BINARY
5657} ;
5758
59+ /**
60+ * Walk the current diff list tree.
61+ *
62+ * @fires DiffList#delta
63+ * @fires DiffList#end
64+ *
65+ * @return {EventEmitter } diffListWalkEmitter
66+ */
5867DiffList . prototype . walk = function ( ) {
5968 var event = new events . EventEmitter ( ) ,
6069 allFileDeltas = [ ] ,
@@ -65,14 +74,30 @@ DiffList.prototype.walk = function() {
6574 event . emit ( 'end' , new git . error ( error . message , error . code ) , null ) ;
6675 }
6776 fileDeltas . forEach ( function ( fileDelta ) {
68- event . emit ( 'file' , null , fileDelta ) ;
77+ /**
78+ * Delta event.
79+ *
80+ * @event DiffList#delta
81+ *
82+ * @param {GitError|null } error An error object if there was an issue, null otherwise.
83+ * @param {FileDelta } fileDelta The file delta object.
84+ */
85+ event . emit ( 'delta' , null , fileDelta ) ;
6986 allFileDeltas . push ( fileDelta ) ;
7087 } ) ;
7188 } , function hunkCallback ( error , diffHunk ) {
7289 /** TO BE IMPLEMENTED */
7390 } , function lineCallback ( error , diffLine ) {
7491 /** TO BE IMPLEMENTED */
7592 } , function endCallback ( error ) {
93+ /**
94+ * End event.
95+ *
96+ * @event DiffList#end
97+ *
98+ * @param {GitError|null } error An error object if there was an issue, null otherwise.
99+ * @param {FileDelta[] } fileDeltas The file delta objects.
100+ */
76101 event . emit ( 'end' , error ? new git . error ( error . message , error . code ) : null , allFileDeltas ) ;
77102 } ) ;
78103
@@ -92,3 +117,49 @@ DiffList.prototype.treeToTree = function(oldSha, newSha, callback) {
92117} ;
93118
94119exports . diffList = DiffList ;
120+
121+ /**
122+ * @namespace
123+ * @property {Object } oldFile Contains details for the old file state
124+ * @property {String } oldFile.path The path to the old file, relative to the repository
125+ * @property {Object } newFile Contains details for the new file state
126+ * @property {String } newFile.path The path to the new file, relative to the repository
127+ * @property {Object[] } content Array of context & differences
128+ * @property {Object } content[].range
129+ * @property {Object } content[].range.old
130+ * @property {Integer } content[].range.old.start
131+ * @property {Integer } content[].range.old.lines
132+ * @property {Object } content[].range.new
133+ * @property {Integer } content[].range.new.start
134+ * @property {Integer } content[].range.new.lines
135+ * @property {Object } content[].content Content of the delta
136+ * @property {DiffList.lineOriginTypes } content[].lineOrigin
137+ * @property {Integer } content[].contentLength
138+ * @property {Integer } status Type of delta
139+ */
140+ var FileDelta = {
141+ oldFile : {
142+ path : String
143+ } ,
144+ newFile : {
145+ path : String
146+ } ,
147+ content : [
148+ {
149+ range : {
150+ old : {
151+ start : Number ,
152+ lines : Number
153+ } ,
154+ 'new' : {
155+ start : Number ,
156+ lines : Number
157+ }
158+ } ,
159+ content : String ,
160+ lineOrigin : String ,
161+ contentLength : Number
162+ }
163+ ] ,
164+ status : Number
165+ } ;
0 commit comments