History

Update Git documentation (2.30.0)

Simon Legner committed 5 years ago

Commit 3600a9f1 parent 8f17cfa41 files · +4398 −1Browse files

Showing the changes to node_modules/simple-git/src/responses/ListLogSummary.js (1 of 41 files). Show all

Unified · Split

node_modules/simple-git/src/responses/ListLogSummary.js+72−0
@@ -0,0 +1,72 @@
1+
2+module.exports = ListLogSummary;
3+
4+var DiffSummary = require('./DiffSummary');
5+
6+/**
7+ * The ListLogSummary is returned as a response to getting `git().log()` or `git().stashList()`
8+ *
9+ * @constructor
10+ */
11+function ListLogSummary (all) {
12+ this.all = all;
13+ this.latest = all.length && all[0] || null;
14+ this.total = all.length;
15+}
16+
17+/**
18+ * Detail for each of the log lines
19+ * @type {ListLogLine[]}
20+ */
21+ListLogSummary.prototype.all = null;
22+
23+/**
24+ * Most recent entry in the log
25+ * @type {ListLogLine}
26+ */
27+ListLogSummary.prototype.latest = null;
28+
29+/**
30+ * Number of items in the log
31+ * @type {number}
32+ */
33+ListLogSummary.prototype.total = 0;
34+
35+function ListLogLine (line, fields) {
36+ for (var k = 0; k < fields.length; k++) {
37+ this[fields[k]] = line[k] || '';
38+ }
39+}
40+
41+/**
42+ * When the log was generated with a summary, the `diff` property contains as much detail
43+ * as was provided in the log (whether generated with `--stat` or `--shortstat`.
44+ * @type {DiffSummary}
45+ */
46+ListLogLine.prototype.diff = null;
47+
48+ListLogSummary.START_BOUNDARY = 'òòòòòò ';
49+
50+ListLogSummary.COMMIT_BOUNDARY = ' òò';
51+
52+ListLogSummary.SPLITTER = ' ò ';
53+
54+ListLogSummary.parse = function (text, splitter, fields) {
55+ fields = fields || ['hash', 'date', 'message', 'refs', 'author_name', 'author_email'];
56+ return new ListLogSummary(
57+ text
58+ .trim()
59+ .split(ListLogSummary.START_BOUNDARY)
60+ .filter(function(item) { return !!item.trim(); })
61+ .map(function (item) {
62+ var lineDetail = item.trim().split(ListLogSummary.COMMIT_BOUNDARY);
63+ var listLogLine = new ListLogLine(lineDetail[0].trim().split(splitter), fields);
64+
65+ if (lineDetail.length > 1 && !!lineDetail[1].trim()) {
66+ listLogLine.diff = DiffSummary.parse(lineDetail[1]);
67+ }
68+
69+ return listLogLine;
70+ })
71+ );
72+};

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t