| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,9 +3,10 @@ var git = require('../'), | |||
| 3 | 3 | ||
| 4 | 4 | /** | |
| 5 | 5 | * Convenience diff list class. | |
| 6 | - * | ||
| 6 | + * | ||
| 7 | + * @constructor | ||
| 7 | 8 | * @param {git.raw.Repo} rawRepo | |
| 8 | - * @param {[type]} rawDiffList [description] | ||
| 9 | + * @param {git.raw.DiffList} [rawDiffList = new git.raw.DiffList] | ||
| 9 | 10 | */ | |
| 10 | 11 | var DiffList = function(rawRepo, rawDiffList) { | |
| 11 | 12 | if (!(rawRepo instanceof git.raw.Repo)) { | |
@@ -55,6 +56,14 @@ DiffList.prototype.lineOriginTypes = { | |||
| 55 | 56 | /** 'B' */ GIT_DIFF_LINE_BINARY: git.raw.DiffList.lineOriginTypes.GIT_DIFF_LINE_BINARY | |
| 56 | 57 | }; | |
| 57 | 58 | ||
| 59 | + /** | ||
| 60 | + * Walk the current diff list tree. | ||
| 61 | + * | ||
| 62 | + * @fires DiffList#delta | ||
| 63 | + * @fires DiffList#end | ||
| 64 | + * | ||
| 65 | + * @return {EventEmitter} diffListWalkEmitter | ||
| 66 | + */ | ||
| 58 | 67 | DiffList.prototype.walk = function() { | |
| 59 | 68 | var event = new events.EventEmitter(), | |
| 60 | 69 | allFileDeltas = [], | |
@@ -65,14 +74,30 @@ DiffList.prototype.walk = function() { | |||
| 65 | 74 | event.emit('end', new git.error(error.message, error.code), null); | |
| 66 | 75 | } | |
| 67 | 76 | 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); | ||
| 69 | 86 | allFileDeltas.push(fileDelta); | |
| 70 | 87 | }); | |
| 71 | 88 | }, function hunkCallback(error, diffHunk) { | |
| 72 | 89 | /** TO BE IMPLEMENTED */ | |
| 73 | 90 | }, function lineCallback(error, diffLine) { | |
| 74 | 91 | /** TO BE IMPLEMENTED */ | |
| 75 | 92 | }, 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 | + */ | ||
| 76 | 101 | event.emit('end', error ? new git.error(error.message, error.code) : null, allFileDeltas); | |
| 77 | 102 | }); | |
| 78 | 103 | ||
@@ -92,3 +117,49 @@ DiffList.prototype.treeToTree = function(oldSha, newSha, callback) { | |||
| 92 | 117 | }; | |
| 93 | 118 | ||
| 94 | 119 | exports.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 | + }; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments