UNPKG

641 BJavaScriptView Raw
1
2module.exports = MoveSummary;
3
4/**
5 * The MoveSummary is returned as a response to getting `git().status()`
6 *
7 * @constructor
8 */
9function MoveSummary () {
10 this.moves = [];
11 this.sources = {};
12}
13
14MoveSummary.SUMMARY_REGEX = /^Renaming (.+) to (.+)$/;
15
16MoveSummary.parse = function (text) {
17 var lines = text.split('\n');
18 var summary = new MoveSummary();
19
20 for (var i = 0, iMax = lines.length, line; i < iMax; i++) {
21 line = MoveSummary.SUMMARY_REGEX.exec(lines[i].trim());
22
23 if (line) {
24 summary.moves.push({
25 from: line[1],
26 to: line[2]
27 });
28 }
29 }
30
31 return summary;
32};