danger 11.3.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/Dockerfile +2 -2
- package/distribution/commands/danger-pr.js +3 -4
- package/distribution/commands/danger-pr.js.map +1 -1
- package/distribution/danger.d.ts +5 -4
- package/distribution/danger.js.flow +7 -2
- package/distribution/dsl/GitDSL.d.ts +2 -0
- package/distribution/dsl/GitLabDSL.d.ts +3 -4
- package/distribution/platforms/FakePlatform.js +1 -1
- package/distribution/platforms/FakePlatform.js.map +1 -1
- package/distribution/platforms/GitLab.d.ts +8 -6
- package/distribution/platforms/GitLab.js +137 -78
- package/distribution/platforms/GitLab.js.map +1 -1
- package/distribution/platforms/encodingParser.d.ts +6 -0
- package/distribution/platforms/encodingParser.js +15 -0
- package/distribution/platforms/encodingParser.js.map +1 -0
- package/distribution/platforms/git/gitJSONToGitDSL.js +5 -1
- package/distribution/platforms/git/gitJSONToGitDSL.js.map +1 -1
- package/distribution/platforms/github/GitHubAPI.js +8 -14
- package/distribution/platforms/github/GitHubAPI.js.map +1 -1
- package/distribution/platforms/github/GitHubUtils.d.ts +2 -2
- package/distribution/platforms/github/GitHubUtils.js +4 -2
- package/distribution/platforms/github/GitHubUtils.js.map +1 -1
- package/distribution/platforms/github/customGitHubRequire.d.ts +1 -1
- package/distribution/platforms/github/customGitHubRequire.js +1 -1
- package/distribution/platforms/github/customGitHubRequire.js.map +1 -1
- package/distribution/platforms/gitlab/GitLabAPI.d.ts +23 -17
- package/distribution/platforms/gitlab/GitLabAPI.js +138 -73
- package/distribution/platforms/gitlab/GitLabAPI.js.map +1 -1
- package/distribution/platforms/gitlab/GitLabGit.d.ts +1 -1
- package/distribution/platforms/gitlab/inlinePositionParser.d.ts +14 -0
- package/distribution/platforms/gitlab/inlinePositionParser.js +125 -0
- package/distribution/platforms/gitlab/inlinePositionParser.js.map +1 -0
- package/package.json +17 -18
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45,10 +56,11 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
45
56
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
57
|
};
|
|
47
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.getGitLabAPICredentialsFromEnv = void 0;
|
|
49
|
-
var
|
|
59
|
+
exports.getGitLabAPICredentialsFromEnv = exports.getGitLabHostFromEnv = void 0;
|
|
60
|
+
var rest_1 = require("@gitbeaker/rest");
|
|
50
61
|
var debug_1 = require("../../debug");
|
|
51
|
-
|
|
62
|
+
var encodingParser_1 = require("../encodingParser");
|
|
63
|
+
function getGitLabHostFromEnv(env) {
|
|
52
64
|
var host = "https://gitlab.com";
|
|
53
65
|
var envHost = env["DANGER_GITLAB_HOST"];
|
|
54
66
|
var envCIAPI = env["CI_API_V4_URL"];
|
|
@@ -69,11 +81,28 @@ function getGitLabAPICredentialsFromEnv(env) {
|
|
|
69
81
|
host = "".concat(matchProto, "://").concat(matchHost);
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
return host;
|
|
85
|
+
}
|
|
86
|
+
exports.getGitLabHostFromEnv = getGitLabHostFromEnv;
|
|
87
|
+
function getGitLabAPICredentialsFromEnv(env) {
|
|
88
|
+
var host = getGitLabHostFromEnv(env);
|
|
89
|
+
var envToken = env["DANGER_GITLAB_API_TOKEN"];
|
|
90
|
+
var envOAuthToken = env["DANGER_GITLAB_API_OAUTH_TOKEN"];
|
|
91
|
+
if (envToken) {
|
|
92
|
+
return {
|
|
93
|
+
host: host,
|
|
94
|
+
token: envToken,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
else if (envOAuthToken) {
|
|
98
|
+
return {
|
|
99
|
+
host: host,
|
|
100
|
+
oauthToken: envOAuthToken,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw new ReferenceError("DANGER_GITLAB_API_TOKEN or DANGER_GITLAB_API_OAUTH_TOKEN must be available in the environment");
|
|
105
|
+
}
|
|
77
106
|
}
|
|
78
107
|
exports.getGitLabAPICredentialsFromEnv = getGitLabAPICredentialsFromEnv;
|
|
79
108
|
var GitLabAPI = /** @class */ (function () {
|
|
@@ -88,7 +117,7 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
88
117
|
switch (_a.label) {
|
|
89
118
|
case 0:
|
|
90
119
|
this.d("getUser");
|
|
91
|
-
return [4 /*yield*/, this.api.Users.
|
|
120
|
+
return [4 /*yield*/, this.api.Users.showCurrentUser()];
|
|
92
121
|
case 1:
|
|
93
122
|
user = (_a.sent());
|
|
94
123
|
this.d("getUser", user);
|
|
@@ -113,9 +142,13 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
113
142
|
this.updateMergeRequestInfo = function (changes) { return __awaiter(_this, void 0, void 0, function () {
|
|
114
143
|
var mr;
|
|
115
144
|
return __generator(this, function (_a) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
145
|
+
switch (_a.label) {
|
|
146
|
+
case 0: return [4 /*yield*/, this.api.MergeRequests.edit(this.repoSlug, this.prId, changes)];
|
|
147
|
+
case 1:
|
|
148
|
+
mr = _a.sent();
|
|
149
|
+
this.d("updateMergeRequestInfo", mr);
|
|
150
|
+
return [2 /*return*/, mr];
|
|
151
|
+
}
|
|
119
152
|
});
|
|
120
153
|
}); };
|
|
121
154
|
this.getMergeRequestApprovals = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -124,8 +157,8 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
124
157
|
switch (_a.label) {
|
|
125
158
|
case 0:
|
|
126
159
|
this.d("getMergeRequestApprovals for repo: ".concat(this.repoSlug, " pr: ").concat(this.prId));
|
|
127
|
-
return [4 /*yield*/, this.api.MergeRequestApprovals.
|
|
128
|
-
|
|
160
|
+
return [4 /*yield*/, this.api.MergeRequestApprovals.showConfiguration(this.repoSlug, {
|
|
161
|
+
mergerequestIId: this.prId,
|
|
129
162
|
})];
|
|
130
163
|
case 1:
|
|
131
164
|
approvals = _a.sent();
|
|
@@ -134,17 +167,17 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
134
167
|
}
|
|
135
168
|
});
|
|
136
169
|
}); };
|
|
137
|
-
this.
|
|
138
|
-
var
|
|
170
|
+
this.getMergeRequestDiffs = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
171
|
+
var allDiffs;
|
|
139
172
|
return __generator(this, function (_a) {
|
|
140
173
|
switch (_a.label) {
|
|
141
174
|
case 0:
|
|
142
175
|
this.d("getMergeRequestChanges for repo: ".concat(this.repoSlug, " pr: ").concat(this.prId));
|
|
143
|
-
return [4 /*yield*/, this.api.MergeRequests.
|
|
176
|
+
return [4 /*yield*/, this.api.MergeRequests.allDiffs(this.repoSlug, this.prId)];
|
|
144
177
|
case 1:
|
|
145
|
-
|
|
146
|
-
this.d("getMergeRequestChanges",
|
|
147
|
-
return [2 /*return*/,
|
|
178
|
+
allDiffs = _a.sent();
|
|
179
|
+
this.d("getMergeRequestChanges", allDiffs);
|
|
180
|
+
return [2 /*return*/, allDiffs];
|
|
148
181
|
}
|
|
149
182
|
});
|
|
150
183
|
}); };
|
|
@@ -154,7 +187,7 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
154
187
|
switch (_a.label) {
|
|
155
188
|
case 0:
|
|
156
189
|
this.d("getMergeRequestCommits", this.repoSlug, this.prId);
|
|
157
|
-
return [4 /*yield*/, this.api.MergeRequests.
|
|
190
|
+
return [4 /*yield*/, this.api.MergeRequests.allCommits(this.repoSlug, this.prId)];
|
|
158
191
|
case 1:
|
|
159
192
|
commits = _a.sent();
|
|
160
193
|
this.d("getMergeRequestCommits", commits);
|
|
@@ -192,21 +225,6 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
192
225
|
}
|
|
193
226
|
});
|
|
194
227
|
}); };
|
|
195
|
-
this.getMergeRequestInlineNotes = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
196
|
-
var notes, inlineNotes;
|
|
197
|
-
return __generator(this, function (_a) {
|
|
198
|
-
switch (_a.label) {
|
|
199
|
-
case 0:
|
|
200
|
-
this.d("getMergeRequestInlineNotes");
|
|
201
|
-
return [4 /*yield*/, this.getMergeRequestNotes()];
|
|
202
|
-
case 1:
|
|
203
|
-
notes = _a.sent();
|
|
204
|
-
inlineNotes = notes.filter(function (note) { return note.type == "DiffNote"; });
|
|
205
|
-
this.d("getMergeRequestInlineNotes", inlineNotes);
|
|
206
|
-
return [2 /*return*/, inlineNotes];
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}); };
|
|
210
228
|
this.createMergeRequestDiscussion = function (content, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
211
229
|
var api, result, e_1;
|
|
212
230
|
return __generator(this, function (_a) {
|
|
@@ -239,7 +257,6 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
239
257
|
_a.label = 1;
|
|
240
258
|
case 1:
|
|
241
259
|
_a.trys.push([1, 3, , 4]);
|
|
242
|
-
this.d("createMergeRequestNote");
|
|
243
260
|
return [4 /*yield*/, this.api.MergeRequestNotes.create(this.repoSlug, this.prId, body)];
|
|
244
261
|
case 2:
|
|
245
262
|
note = _a.sent();
|
|
@@ -253,8 +270,30 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
253
270
|
}
|
|
254
271
|
});
|
|
255
272
|
}); };
|
|
273
|
+
this.updateMergeRequestDiscussionNote = function (discussionId, noteId, body) { return __awaiter(_this, void 0, void 0, function () {
|
|
274
|
+
var discussionNote, e_3;
|
|
275
|
+
return __generator(this, function (_a) {
|
|
276
|
+
switch (_a.label) {
|
|
277
|
+
case 0:
|
|
278
|
+
this.d("updateMergeRequestDiscussionNote", this.repoSlug, this.prId, discussionId, noteId, body);
|
|
279
|
+
_a.label = 1;
|
|
280
|
+
case 1:
|
|
281
|
+
_a.trys.push([1, 3, , 4]);
|
|
282
|
+
return [4 /*yield*/, this.api.MergeRequestDiscussions.editNote(this.repoSlug, this.prId, discussionId, noteId, { body: body })];
|
|
283
|
+
case 2:
|
|
284
|
+
discussionNote = _a.sent();
|
|
285
|
+
this.d("updateMergeRequestDiscussionNote", discussionNote);
|
|
286
|
+
return [2 /*return*/, discussionNote];
|
|
287
|
+
case 3:
|
|
288
|
+
e_3 = _a.sent();
|
|
289
|
+
this.d("updateMergeRequestDiscussionNote", e_3);
|
|
290
|
+
return [3 /*break*/, 4];
|
|
291
|
+
case 4: return [2 /*return*/, Promise.reject()];
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}); };
|
|
256
295
|
this.updateMergeRequestNote = function (id, body) { return __awaiter(_this, void 0, void 0, function () {
|
|
257
|
-
var note,
|
|
296
|
+
var note, e_4;
|
|
258
297
|
return __generator(this, function (_a) {
|
|
259
298
|
switch (_a.label) {
|
|
260
299
|
case 0:
|
|
@@ -262,22 +301,44 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
262
301
|
_a.label = 1;
|
|
263
302
|
case 1:
|
|
264
303
|
_a.trys.push([1, 3, , 4]);
|
|
265
|
-
return [4 /*yield*/, this.api.MergeRequestNotes.edit(this.repoSlug, this.prId, id, body)];
|
|
304
|
+
return [4 /*yield*/, this.api.MergeRequestNotes.edit(this.repoSlug, this.prId, id, { body: body })];
|
|
266
305
|
case 2:
|
|
267
306
|
note = _a.sent();
|
|
268
307
|
this.d("updateMergeRequestNote", note);
|
|
269
308
|
return [2 /*return*/, note];
|
|
270
309
|
case 3:
|
|
271
|
-
|
|
272
|
-
this.d("updateMergeRequestNote",
|
|
310
|
+
e_4 = _a.sent();
|
|
311
|
+
this.d("updateMergeRequestNote", e_4);
|
|
273
312
|
return [3 /*break*/, 4];
|
|
274
313
|
case 4: return [2 /*return*/, Promise.reject()];
|
|
275
314
|
}
|
|
276
315
|
});
|
|
277
316
|
}); };
|
|
278
|
-
// note: deleting the _only_ note in a discussion also deletes the discussion \o/
|
|
317
|
+
// note: deleting the _only_ discussion note in a discussion also deletes the discussion \o/
|
|
318
|
+
this.deleteMergeRequestDiscussionNote = function (discussionId, noteId) { return __awaiter(_this, void 0, void 0, function () {
|
|
319
|
+
var e_5;
|
|
320
|
+
return __generator(this, function (_a) {
|
|
321
|
+
switch (_a.label) {
|
|
322
|
+
case 0:
|
|
323
|
+
this.d("deleteMergeRequestDiscussionNote", this.repoSlug, this.prId, discussionId, noteId);
|
|
324
|
+
_a.label = 1;
|
|
325
|
+
case 1:
|
|
326
|
+
_a.trys.push([1, 3, , 4]);
|
|
327
|
+
return [4 /*yield*/, this.api.MergeRequestDiscussions.removeNote(this.repoSlug, this.prId, discussionId, noteId)];
|
|
328
|
+
case 2:
|
|
329
|
+
_a.sent();
|
|
330
|
+
this.d("deleteMergeRequestDiscussionNote", true);
|
|
331
|
+
return [2 /*return*/, true];
|
|
332
|
+
case 3:
|
|
333
|
+
e_5 = _a.sent();
|
|
334
|
+
this.d("deleteMergeRequestDiscussionNote", e_5);
|
|
335
|
+
return [2 /*return*/, false];
|
|
336
|
+
case 4: return [2 /*return*/];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}); };
|
|
279
340
|
this.deleteMergeRequestNote = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
280
|
-
var
|
|
341
|
+
var e_6;
|
|
281
342
|
return __generator(this, function (_a) {
|
|
282
343
|
switch (_a.label) {
|
|
283
344
|
case 0:
|
|
@@ -291,17 +352,18 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
291
352
|
this.d("deleteMergeRequestNote", true);
|
|
292
353
|
return [2 /*return*/, true];
|
|
293
354
|
case 3:
|
|
294
|
-
|
|
295
|
-
this.d("deleteMergeRequestNote",
|
|
355
|
+
e_6 = _a.sent();
|
|
356
|
+
this.d("deleteMergeRequestNote", e_6);
|
|
296
357
|
return [2 /*return*/, false];
|
|
297
358
|
case 4: return [2 /*return*/];
|
|
298
359
|
}
|
|
299
360
|
});
|
|
300
361
|
}); };
|
|
301
362
|
this.getFileContents = function (path, slug, ref) { return __awaiter(_this, void 0, void 0, function () {
|
|
302
|
-
var api, projectId, mr, response, result,
|
|
303
|
-
|
|
304
|
-
|
|
363
|
+
var api, projectId, mr, response, encoding, result, e_7;
|
|
364
|
+
var _a;
|
|
365
|
+
return __generator(this, function (_b) {
|
|
366
|
+
switch (_b.label) {
|
|
305
367
|
case 0:
|
|
306
368
|
this.d("getFileContents requested for path:".concat(path, ", slug:").concat(slug, ", ref:").concat(ref));
|
|
307
369
|
api = this.api.RepositoryFiles;
|
|
@@ -309,44 +371,47 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
309
371
|
if (!!ref) return [3 /*break*/, 2];
|
|
310
372
|
return [4 /*yield*/, this.getMergeRequestInfo()];
|
|
311
373
|
case 1:
|
|
312
|
-
mr =
|
|
374
|
+
mr = _b.sent();
|
|
313
375
|
ref = mr.diff_refs.head_sha;
|
|
314
|
-
|
|
376
|
+
_b.label = 2;
|
|
315
377
|
case 2:
|
|
316
|
-
|
|
378
|
+
_b.trys.push([2, 4, , 5]);
|
|
317
379
|
this.d("getFileContents", projectId, path, ref);
|
|
318
380
|
return [4 /*yield*/, api.show(projectId, path, ref)];
|
|
319
381
|
case 3:
|
|
320
|
-
response =
|
|
321
|
-
|
|
382
|
+
response = _b.sent();
|
|
383
|
+
encoding = (0, encodingParser_1.encodingParser)(response.encoding);
|
|
384
|
+
result = Buffer.from(response.content, encoding).toString();
|
|
322
385
|
this.d("getFileContents", result);
|
|
323
386
|
return [2 /*return*/, result];
|
|
324
387
|
case 4:
|
|
325
|
-
|
|
326
|
-
this.d("getFileContents",
|
|
388
|
+
e_7 = _b.sent();
|
|
389
|
+
this.d("getFileContents", e_7);
|
|
327
390
|
// GitHubAPI.fileContents returns "" when the file does not exist, keep it consistent across providers
|
|
328
|
-
if (
|
|
391
|
+
if (((_a = e_7.cause) === null || _a === void 0 ? void 0 : _a.response.status) === 404) {
|
|
329
392
|
return [2 /*return*/, ""];
|
|
330
393
|
}
|
|
331
|
-
throw
|
|
394
|
+
throw e_7;
|
|
332
395
|
case 5: return [2 /*return*/];
|
|
333
396
|
}
|
|
334
397
|
});
|
|
335
398
|
}); };
|
|
336
399
|
this.getCompareChanges = function (base, head) { return __awaiter(_this, void 0, void 0, function () {
|
|
337
|
-
var api, projectId, compare;
|
|
338
|
-
|
|
339
|
-
|
|
400
|
+
var api, projectId, compare, diffs;
|
|
401
|
+
var _a;
|
|
402
|
+
return __generator(this, function (_b) {
|
|
403
|
+
switch (_b.label) {
|
|
340
404
|
case 0:
|
|
341
405
|
if (!base || !head) {
|
|
342
|
-
return [2 /*return*/, this.
|
|
406
|
+
return [2 /*return*/, this.getMergeRequestDiffs()];
|
|
343
407
|
}
|
|
344
408
|
api = this.api.Repositories;
|
|
345
409
|
projectId = this.repoSlug;
|
|
346
410
|
return [4 /*yield*/, api.compare(projectId, base, head)];
|
|
347
411
|
case 1:
|
|
348
|
-
compare =
|
|
349
|
-
|
|
412
|
+
compare = _b.sent();
|
|
413
|
+
diffs = (_a = compare.diffs) !== null && _a !== void 0 ? _a : [];
|
|
414
|
+
return [2 /*return*/, diffs];
|
|
350
415
|
}
|
|
351
416
|
});
|
|
352
417
|
}); };
|
|
@@ -377,29 +442,29 @@ var GitLabAPI = /** @class */ (function () {
|
|
|
377
442
|
labels[_i] = arguments[_i];
|
|
378
443
|
}
|
|
379
444
|
return __awaiter(_this, void 0, void 0, function () {
|
|
380
|
-
var mr, _a, labels_1, label, index;
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
switch (_e.label) {
|
|
445
|
+
var mr, mrLabels, _a, labels_1, label, index;
|
|
446
|
+
return __generator(this, function (_b) {
|
|
447
|
+
switch (_b.label) {
|
|
384
448
|
case 0: return [4 /*yield*/, this.getMergeRequestInfo()];
|
|
385
449
|
case 1:
|
|
386
|
-
mr =
|
|
450
|
+
mr = _b.sent();
|
|
451
|
+
mrLabels = mr.labels;
|
|
387
452
|
for (_a = 0, labels_1 = labels; _a < labels_1.length; _a++) {
|
|
388
453
|
label = labels_1[_a];
|
|
389
|
-
index =
|
|
454
|
+
index = mrLabels.indexOf(label);
|
|
390
455
|
if (index > -1) {
|
|
391
|
-
|
|
456
|
+
mrLabels.splice(index, 1);
|
|
392
457
|
}
|
|
393
458
|
}
|
|
394
|
-
return [4 /*yield*/, this.updateMergeRequestInfo({ labels:
|
|
459
|
+
return [4 /*yield*/, this.updateMergeRequestInfo({ labels: mrLabels.join(",") })];
|
|
395
460
|
case 2:
|
|
396
|
-
|
|
461
|
+
_b.sent();
|
|
397
462
|
return [2 /*return*/, true];
|
|
398
463
|
}
|
|
399
464
|
});
|
|
400
465
|
});
|
|
401
466
|
};
|
|
402
|
-
this.api = new
|
|
467
|
+
this.api = new rest_1.Gitlab(__assign({}, repoCredentials));
|
|
403
468
|
this.hostURL = repoCredentials.host;
|
|
404
469
|
this.repoSlug = repoMetadata.repoSlug;
|
|
405
470
|
this.prId = Number(repoMetadata.pullRequestID);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitLabAPI.js","sourceRoot":"","sources":["../../../source/platforms/gitlab/GitLabAPI.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3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aAAa,CAAC,CAAA;IAChD,CAAC;IAED,sBAAI,iCAAU;aAAd;YACE,OAAO,UAAG,IAAI,CAAC,OAAO,cAAI,IAAI,CAAC,QAAQ,CAAE,CAAA;QAC3C,CAAC;;;OAAA;IAED,sBAAI,sCAAe;aAAnB;YACE,OAAO,UAAG,IAAI,CAAC,UAAU,6BAAmB,IAAI,CAAC,IAAI,CAAE,CAAA;QACzD,CAAC;;;OAAA;IAED,sBAAI,kCAAW;aAAf;YACE,OAAO,IAAI,CAAC,GAAG,CAAA;QACjB,CAAC;;;OAAA;IAoNH,gBAAC;AAAD,CAAC,AA5OD,IA4OC;AAED,kBAAe,SAAS,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GitLabDSL } from "../../dsl/GitLabDSL";
|
|
2
2
|
import { GitDSL, GitJSONDSL } from "../../dsl/GitDSL";
|
|
3
|
-
import
|
|
3
|
+
import type * as Types from "@gitbeaker/rest";
|
|
4
4
|
import GitLabAPI from "./GitLabAPI";
|
|
5
5
|
export declare const gitLabGitDSL: (gitlab: GitLabDSL, json: GitJSONDSL, gitlabAPI: GitLabAPI) => GitDSL;
|
|
6
6
|
export declare const gitlabChangesToDiff: (changes: Types.CommitDiffSchema[]) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StructuredDiff } from "../../dsl/GitDSL";
|
|
2
|
+
export interface InlinePosition {
|
|
3
|
+
pathDiff: PathDiff;
|
|
4
|
+
lineDiff: LineDiff;
|
|
5
|
+
}
|
|
6
|
+
export interface PathDiff {
|
|
7
|
+
oldPath: string | undefined;
|
|
8
|
+
newPath: string;
|
|
9
|
+
}
|
|
10
|
+
export interface LineDiff {
|
|
11
|
+
oldLine: number | undefined;
|
|
12
|
+
newLine: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare function inlinePositionParser(structuredDiff: StructuredDiff, path: string, line: number): InlinePosition;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inlinePositionParser = void 0;
|
|
4
|
+
var debug_1 = require("../../debug");
|
|
5
|
+
var d = (0, debug_1.debug)("GitLab inlinePositionParser");
|
|
6
|
+
function inlinePositionParser(structuredDiff, path, line) {
|
|
7
|
+
d("structuredDiff", structuredDiff);
|
|
8
|
+
var lineDiff = calculateLineDiff(structuredDiff, line);
|
|
9
|
+
return {
|
|
10
|
+
pathDiff: {
|
|
11
|
+
oldPath: structuredDiff.fromPath,
|
|
12
|
+
newPath: path,
|
|
13
|
+
},
|
|
14
|
+
lineDiff: lineDiff,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.inlinePositionParser = inlinePositionParser;
|
|
18
|
+
function calculateLineDiff(diff, line) {
|
|
19
|
+
var chunk = findRelevantChunk(diff, line);
|
|
20
|
+
d("calculateLineDiff found chunk", { line: line, chunk: chunk, changes: chunk === null || chunk === void 0 ? void 0 : chunk.changes });
|
|
21
|
+
if (!chunk) {
|
|
22
|
+
return {
|
|
23
|
+
oldLine: line,
|
|
24
|
+
newLine: line,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (chunk.newStart <= line && line <= chunk.newStart + chunk.newLines) {
|
|
28
|
+
var change = chunk.changes.find(function (change) {
|
|
29
|
+
switch (change.type) {
|
|
30
|
+
case "add":
|
|
31
|
+
return change.ln === line;
|
|
32
|
+
case "del":
|
|
33
|
+
return false;
|
|
34
|
+
case "normal":
|
|
35
|
+
return change.ln2 === line;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
// If there is no relevant change we return the requested line.
|
|
39
|
+
if (!change || change.type === "del") {
|
|
40
|
+
return {
|
|
41
|
+
oldLine: line,
|
|
42
|
+
newLine: line,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
switch (change.type) {
|
|
46
|
+
case "add":
|
|
47
|
+
return {
|
|
48
|
+
oldLine: undefined,
|
|
49
|
+
newLine: change.ln,
|
|
50
|
+
};
|
|
51
|
+
case "normal":
|
|
52
|
+
return {
|
|
53
|
+
oldLine: change.ln1,
|
|
54
|
+
newLine: change.ln2,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (line < chunk.newStart) {
|
|
59
|
+
d("calculateLineDiff line below changes in file", { line: line });
|
|
60
|
+
return {
|
|
61
|
+
oldLine: line,
|
|
62
|
+
newLine: line,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
var offset = chunk.newStart + chunk.newLines - (chunk.oldStart + chunk.oldLines);
|
|
67
|
+
d("calculateLineDiff line above changes in file", { line: line, offset: offset });
|
|
68
|
+
return {
|
|
69
|
+
oldLine: line - offset,
|
|
70
|
+
newLine: line,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Find the most relevant chunk using a binary search approach.
|
|
75
|
+
// A chunk containing changes with the line is preferred.
|
|
76
|
+
// If none exists then a chunk with the nearest newStart below the line is preferred.
|
|
77
|
+
// Only if no other chunks exists is the first chunk above the line returned.
|
|
78
|
+
function findRelevantChunk(diff, line) {
|
|
79
|
+
var chunks = diff.chunks;
|
|
80
|
+
if (chunks.length == 0) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
var startIndex = 0;
|
|
84
|
+
var endIndex = chunks.length - 1;
|
|
85
|
+
while (true) {
|
|
86
|
+
var currentIndex = Math.floor((startIndex + endIndex) / 2);
|
|
87
|
+
var currentChunk = chunks[currentIndex];
|
|
88
|
+
if (chunkContainsLine(currentChunk, line)) {
|
|
89
|
+
return currentChunk;
|
|
90
|
+
}
|
|
91
|
+
if (currentIndex === startIndex) {
|
|
92
|
+
var endChunk = chunks[endIndex];
|
|
93
|
+
if (!endChunk) {
|
|
94
|
+
return currentChunk;
|
|
95
|
+
}
|
|
96
|
+
if (chunkContainsLine(endChunk, line)) {
|
|
97
|
+
return endChunk;
|
|
98
|
+
}
|
|
99
|
+
if (endChunk.newStart < line) {
|
|
100
|
+
return endChunk;
|
|
101
|
+
}
|
|
102
|
+
if (currentChunk.newStart < line) {
|
|
103
|
+
return currentChunk;
|
|
104
|
+
}
|
|
105
|
+
var currentChunkOffset = Math.abs(currentChunk.newStart - line);
|
|
106
|
+
var endChunkOffset = Math.abs(endChunk.newStart - line);
|
|
107
|
+
if (currentChunkOffset <= endChunkOffset) {
|
|
108
|
+
return currentChunk;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return endChunk;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (currentChunk.newStart < line) {
|
|
115
|
+
startIndex = currentIndex;
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
endIndex = currentIndex;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function chunkContainsLine(chunk, line) {
|
|
123
|
+
return chunk.newStart <= line && line <= chunk.newStart + chunk.newLines;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=inlinePositionParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlinePositionParser.js","sourceRoot":"","sources":["../../../source/platforms/gitlab/inlinePositionParser.ts"],"names":[],"mappings":";;;AACA,qCAAmC;AAGnC,IAAM,CAAC,GAAG,IAAA,aAAK,EAAC,6BAA6B,CAAC,CAAA;AAiB9C,SAAgB,oBAAoB,CAAC,cAA8B,EAAE,IAAY,EAAE,IAAY;IAC7F,CAAC,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAA;IACnC,IAAM,QAAQ,GAAG,iBAAiB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;IACxD,OAAO;QACL,QAAQ,EAAE;YACR,OAAO,EAAE,cAAc,CAAC,QAAQ;YAChC,OAAO,EAAE,IAAI;SACd;QACD,QAAQ,EAAE,QAAQ;KACnB,CAAA;AACH,CAAC;AAVD,oDAUC;AAED,SAAS,iBAAiB,CAAC,IAAoB,EAA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