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
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,21 @@
|
|
|
17
17
|
<!-- Your comment below this -->
|
|
18
18
|
<!-- Your comment above this -->
|
|
19
19
|
|
|
20
|
+
## 12.0.0
|
|
21
|
+
|
|
22
|
+
Bumping to 12.x because we've raised the minimum to node version from 14 to 18. This is due to some of our dependencies
|
|
23
|
+
requiring a newer version of node. This is a breaking change for some folk! Also, 14 has been out of support for quite a while
|
|
24
|
+
now and Node 18 gives us a full year. - [@orta]
|
|
25
|
+
|
|
26
|
+
- Remove the user checks in GitHub comment/inline comment lookups, to allow using app tokens [#1433] - [@orta]
|
|
27
|
+
- Upgrade `node` engine from `>=14.13.1` to `>=18` [@heltoft]
|
|
28
|
+
- Upgrade `@types/node` from `^10.11.3` to `18.19.18` [@heltoft]
|
|
29
|
+
- GitLab: [#1386] Move from `@gitbeaker/node` to `@gitbeaker/rest` [@heltoft]
|
|
30
|
+
- GitLab: [#1412] Danger fails to create inline comments on Gitlab [@heltoft]
|
|
31
|
+
- GitLab: [#1405] Can't post multiple inline comments [@heltoft]
|
|
32
|
+
- GitLab: Do not delete system resolved danger inline comments [@heltoft]
|
|
33
|
+
- Fix for ESM imports in Dangerfiles [@mgol]
|
|
34
|
+
|
|
20
35
|
## 11.3.1
|
|
21
36
|
|
|
22
37
|
- Adds `pull_number` into `thisPR` in the GitHub SDL [@radimsv]
|
|
@@ -2002,6 +2017,7 @@ Not usable for others, only stubs of classes etc. - [@orta]
|
|
|
2002
2017
|
[@hanneskaeufler]: https://github.com/hanneskaeufler
|
|
2003
2018
|
[@happylinks]: https://github.com/happylinks
|
|
2004
2019
|
[@hellocore]: https://github.com/HelloCore
|
|
2020
|
+
[@heltoft]: https://github.com/heltoft
|
|
2005
2021
|
[@hiroppy]: https://github.com/hiroppy
|
|
2006
2022
|
[@hmcc]: https://github.com/hmcc
|
|
2007
2023
|
[@hmschreiner]: https://github.com/hmschreiner
|
package/Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM node:
|
|
1
|
+
FROM node:18-slim as build
|
|
2
2
|
|
|
3
3
|
LABEL maintainer="Orta Therox"
|
|
4
4
|
LABEL "com.github.actions.name"="Danger JS Action"
|
|
@@ -16,7 +16,7 @@ RUN yarn install --production --frozen-lockfile
|
|
|
16
16
|
RUN chmod +x distribution/commands/danger.js
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
FROM node:
|
|
19
|
+
FROM node:18-slim
|
|
20
20
|
WORKDIR /usr/src/danger
|
|
21
21
|
ENV PATH="/usr/src/danger/node_modules/.bin:$PATH"
|
|
22
22
|
COPY package.json ./
|
|
@@ -65,7 +65,6 @@ var platform_1 = require("../platforms/platform");
|
|
|
65
65
|
var GitLabAPI_1 = require("../platforms/gitlab/GitLabAPI");
|
|
66
66
|
var d = (0, debug_1.debug)("pr");
|
|
67
67
|
var log = console.log;
|
|
68
|
-
var gitLabApiCredentials = (0, GitLabAPI_1.getGitLabAPICredentialsFromEnv)(process.env);
|
|
69
68
|
commander_1.default
|
|
70
69
|
.usage("[options] <pr_url>")
|
|
71
70
|
.description("Emulate running Danger against an existing GitHub Pull Request.")
|
|
@@ -80,8 +79,8 @@ commander_1.default
|
|
|
80
79
|
!process.env["DANGER_BITBUCKETCLOUD_OAUTH_KEY"] &&
|
|
81
80
|
!process.env["DANGER_BITBUCKETCLOUD_USERNAME"] &&
|
|
82
81
|
!process.env["DANGER_BITBUCKETCLOUD_REPO_ACCESSTOKEN"] &&
|
|
83
|
-
!
|
|
84
|
-
!
|
|
82
|
+
!process.env["DANGER_GITLAB_API_TOKEN"] &&
|
|
83
|
+
!process.env["DANGER_GITLAB_API_OAUTH_TOKEN"]) {
|
|
85
84
|
log("");
|
|
86
85
|
log(" You don't have a DANGER_GITHUB_API_TOKEN/DANGER_GITLAB_API_TOKEN/DANGER_GITLAB_API_OAUTH_TOKEN/DANGER_BITBUCKETCLOUD_OAUTH_KEY/DANGER_BITBUCKETCLOUD_USERNAME/DANGER_BITBUCKETCLOUD_REPO_ACCESSTOKEN set up, this is optional, but TBH, you want to do this.");
|
|
87
86
|
log(" Check out: http://danger.systems/js/guides/the_dangerfile.html#working-on-your-dangerfile");
|
|
@@ -105,7 +104,7 @@ if (commander_1.default.args.length === 0) {
|
|
|
105
104
|
process.exitCode = 1;
|
|
106
105
|
}
|
|
107
106
|
else {
|
|
108
|
-
var customHost_1 = process.env["DANGER_GITHUB_HOST"] || process.env["DANGER_BITBUCKETSERVER_HOST"] ||
|
|
107
|
+
var customHost_1 = process.env["DANGER_GITHUB_HOST"] || process.env["DANGER_BITBUCKETSERVER_HOST"] || (0, GitLabAPI_1.getGitLabHostFromEnv)(process.env); // This defaults to https://www.gitlab.com
|
|
109
108
|
// Allow an ambiguous amount of args to find the PR reference
|
|
110
109
|
var findPR = commander_1.default.args.find(function (a) { return a.includes(customHost_1) || a.includes("github") || a.includes("bitbucket.org"); });
|
|
111
110
|
if (!findPR) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"danger-pr.js","sourceRoot":"","sources":["../../source/commands/danger-pr.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wDAA+B;AAC/B,kCAAgC;AAChC,0DAAmC;AAEnC,oDAAoD;AACpD,oEAAkE;AAClE,+CAAkD;AAClD,sFAAuE;AACvE,uDAAyD;AACzD,mEAA8D;AAC9D,sCAAuC;AACvC,kDAAmE;AAEnE,
|
|
1
|
+
{"version":3,"file":"danger-pr.js","sourceRoot":"","sources":["../../source/commands/danger-pr.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wDAA+B;AAC/B,kCAAgC;AAChC,0DAAmC;AAEnC,oDAAoD;AACpD,oEAAkE;AAClE,+CAAkD;AAClD,sFAAuE;AACvE,uDAAyD;AACzD,mEAA8D;AAC9D,sCAAuC;AACvC,kDAAmE;AAEnE,2DAAoE;AA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AE,KAAK,EAAE,EAAE,CAAC,CAAA;iBACvF;aACF;SACF;KACF;CACF;AAED,oEAAoE;AACpE,SAAe,kBAAkB,CAAC,QAAkB,EAAE,MAAgB;;;;;wBAClD,qBAAM,IAAA,+BAAgB,EAAC,QAAQ,EAAE,MAAM,EAAE,mBAAO,CAAC;oBACnE,4BAA4B;kBADuC;;oBAA7D,SAAS,GAAG,SAAiD;oBACnE,4BAA4B;oBAC5B,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE;wBACtE,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAA;qBACtG;oBAEK,YAAY,GAAG,IAAA,sCAAgB,EAAC,SAAS,CAAC,CAAA;oBAC1C,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;oBAEvC,IAAI,GAAG,CAAC,IAAI,EAAE;wBACZ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;qBACtD;yBAAM,IAAI,GAAG,CAAC,EAAE,EAAE;wBACjB,OAAO,CAAC,GAAG,CAAC,oBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;qBACvC;;;;;CACF"}
|
package/distribution/danger.d.ts
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Octokit as GitHub } from "@octokit/rest"
|
|
6
|
-
import
|
|
7
|
-
import { Types as CoreTypes } from "@gitbeaker/core/dist"
|
|
6
|
+
import type * as Types from "@gitbeaker/rest"
|
|
8
7
|
import { File } from "parse-diff"
|
|
9
8
|
|
|
10
9
|
type MarkdownString = string
|
|
@@ -833,6 +832,8 @@ interface TextDiff {
|
|
|
833
832
|
interface StructuredDiff {
|
|
834
833
|
/** Git diff chunks */
|
|
835
834
|
chunks: File["chunks"]
|
|
835
|
+
/** The file path pre-change */
|
|
836
|
+
fromPath: string | undefined
|
|
836
837
|
}
|
|
837
838
|
|
|
838
839
|
/** The results of running a JSON patch */
|
|
@@ -1481,7 +1482,7 @@ interface GitLabJSONDSL {
|
|
|
1481
1482
|
/** Info about the repo */
|
|
1482
1483
|
metadata: RepoMetaData
|
|
1483
1484
|
/** Info about the merge request */
|
|
1484
|
-
mr:
|
|
1485
|
+
mr: Types.ExpandedMergeRequestSchema
|
|
1485
1486
|
/** All the individual commits in the merge request */
|
|
1486
1487
|
commits: Types.CommitSchema[]
|
|
1487
1488
|
/** Merge Request-level MR approvals Configuration */
|
|
@@ -1496,7 +1497,7 @@ interface GitLabDSL extends GitLabJSONDSL {
|
|
|
1496
1497
|
addLabels(...labels: string[]): Promise<boolean>
|
|
1497
1498
|
removeLabels(...labels: string[]): Promise<boolean>
|
|
1498
1499
|
}
|
|
1499
|
-
api: InstanceType<typeof Gitlab>
|
|
1500
|
+
api: InstanceType<typeof Types.Gitlab>
|
|
1500
1501
|
}
|
|
1501
1502
|
|
|
1502
1503
|
/** Key details about a repo */
|
|
@@ -1165,6 +1165,11 @@ declare interface StructuredDiff {
|
|
|
1165
1165
|
* Git diff chunks
|
|
1166
1166
|
*/
|
|
1167
1167
|
chunks: "NO PRINT IMPLEMENTED: IndexedAccessType";
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* The file path pre-change
|
|
1171
|
+
*/
|
|
1172
|
+
fromPath: string | void;
|
|
1168
1173
|
}
|
|
1169
1174
|
/**
|
|
1170
1175
|
* The results of running a JSON patch
|
|
@@ -1931,7 +1936,7 @@ declare interface GitLabJSONDSL {
|
|
|
1931
1936
|
/**
|
|
1932
1937
|
* Info about the merge request
|
|
1933
1938
|
*/
|
|
1934
|
-
mr:
|
|
1939
|
+
mr: Types.ExpandedMergeRequestSchema;
|
|
1935
1940
|
|
|
1936
1941
|
/**
|
|
1937
1942
|
* All the individual commits in the merge request
|
|
@@ -1952,7 +1957,7 @@ declare type GitLabDSL = {
|
|
|
1952
1957
|
addLabels(...labels: string[]): Promise<boolean>,
|
|
1953
1958
|
removeLabels(...labels: string[]): Promise<boolean>,
|
|
1954
1959
|
},
|
|
1955
|
-
api: InstanceType<typeof
|
|
1960
|
+
api: InstanceType<typeof undefined>,
|
|
1956
1961
|
} & GitLabJSONDSL
|
|
1957
1962
|
|
|
1958
1963
|
/**
|
|
@@ -18,6 +18,8 @@ export interface TextDiff {
|
|
|
18
18
|
export interface StructuredDiff {
|
|
19
19
|
/** Git diff chunks */
|
|
20
20
|
chunks: File["chunks"];
|
|
21
|
+
/** The file path pre-change */
|
|
22
|
+
fromPath: string | undefined;
|
|
21
23
|
}
|
|
22
24
|
/** The results of running a JSON patch */
|
|
23
25
|
export interface JSONPatch {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type * as Types from "@gitbeaker/rest";
|
|
2
2
|
import { RepoMetaData } from "./RepoMetaData";
|
|
3
|
-
import { Types as CoreTypes } from "@gitbeaker/core/dist";
|
|
4
3
|
export interface GitLabJSONDSL {
|
|
5
4
|
/** Info about the repo */
|
|
6
5
|
metadata: RepoMetaData;
|
|
7
6
|
/** Info about the merge request */
|
|
8
|
-
mr:
|
|
7
|
+
mr: Types.ExpandedMergeRequestSchema;
|
|
9
8
|
/** All the individual commits in the merge request */
|
|
10
9
|
commits: Types.CommitSchema[];
|
|
11
10
|
/** Merge Request-level MR approvals Configuration */
|
|
@@ -18,5 +17,5 @@ export interface GitLabDSL extends GitLabJSONDSL {
|
|
|
18
17
|
addLabels(...labels: string[]): Promise<boolean>;
|
|
19
18
|
removeLabels(...labels: string[]): Promise<boolean>;
|
|
20
19
|
};
|
|
21
|
-
api: InstanceType<typeof Gitlab>;
|
|
20
|
+
api: InstanceType<typeof Types.Gitlab>;
|
|
22
21
|
}
|
|
@@ -77,7 +77,7 @@ var FakePlatform = /** @class */ (function () {
|
|
|
77
77
|
return [2 /*return*/, ({ before: "", after: "", diff: "", added: "", removed: "" })];
|
|
78
78
|
}); }); },
|
|
79
79
|
structuredDiffForFile: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
80
|
-
return [2 /*return*/, ({ chunks: [] })];
|
|
80
|
+
return [2 /*return*/, ({ chunks: [], fromPath: undefined })];
|
|
81
81
|
}); }); },
|
|
82
82
|
JSONDiffForFile: function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
83
83
|
return [2 /*return*/, ({})];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakePlatform.js","sourceRoot":"","sources":["../../source/platforms/FakePlatform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8EAAuD;AAEvD,yBAAiC;AAEjC;IAGE;QA8EA,oBAAe,GAAG,UAAC,IAAY,IAAK,OAAA,IAAI,OAAO,CAAS,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,IAAA,iBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAA/B,CAA+B,CAAC,EAA7D,CAA6D,CAAA;QAEjG,uBAAkB,GAChB,SAAS,CAAA;QAhFT,IAAI,CAAC,IAAI,GAAG,MAAM,CAAA;IACpB,CAAC;IAEK,oCAAa,GAAnB;;;gBACE,sBAAO,EAAE,EAAA;;;KACV;IAEK,yDAAkC,GAAxC;;;gBACE,sBAAO,EAAE,EAAA;;;KACV;IAEK,mDAA4B,GAAlC;;;;gBACE,sBAAO;wBACL,IAAI,EAAE,KAAK;wBACX,IAAI,EAAE,KAAK;wBACX,cAAc,EAAE,EAAE;wBAClB,aAAa,EAAE,EAAE;wBACjB,aAAa,EAAE,EAAE;wBACjB,SAAS,EAAE,IAAA,qBAAW,EAAC,EAAE,QAAQ,E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AI,EAAA;;;KACZ;IAEK,0CAAmB,GAAzB,UAA0B,IAAY,EAAE,QAAgB,EAAE,KAAa,EAAE,KAAa;;;gBACpF,sBAAO,IAAI,EAAA;;;KACZ;IAEK,0CAAmB,GAAzB,UAA0B,QAAgB,EAAE,UAAkB;;;gBAC5D,sBAAO,IAAI,EAAA;;;KACZ;IAEK,0CAAmB,GAAzB,UAA0B,GAAW;;;gBACnC,sBAAO,IAAI,EAAA;;;KACZ;IAEK,wCAAiB,GAAvB;;;gBACE,sBAAO,IAAI,EAAA;;;KACZ;IAEK,mCAAY,GAAlB;;;gBACE,sBAAO,IAAI,EAAA;;;KACZ;IAMH,mBAAC;AAAD,CAAC,AArFD,IAqFC;AArFY,oCAAY"}
|
|
@@ -2,7 +2,7 @@ import GitLabAPI from "./gitlab/GitLabAPI";
|
|
|
2
2
|
import { Comment, Platform } from "./platform";
|
|
3
3
|
import { GitDSL, GitJSONDSL } from "../dsl/GitDSL";
|
|
4
4
|
import { GitLabDSL, GitLabJSONDSL } from "../dsl/GitLabDSL";
|
|
5
|
-
import
|
|
5
|
+
import type * as Types from "@gitbeaker/rest";
|
|
6
6
|
declare class GitLab implements Platform {
|
|
7
7
|
readonly api: GitLabAPI;
|
|
8
8
|
readonly name: string;
|
|
@@ -14,21 +14,23 @@ declare class GitLab implements Platform {
|
|
|
14
14
|
supportsCommenting(): boolean;
|
|
15
15
|
supportsInlineComments(): boolean;
|
|
16
16
|
updateOrCreateComment: (dangerID: string, newComment: string) => Promise<string>;
|
|
17
|
-
createComment: (_dangerID: string, comment: string) => Promise<Types.
|
|
17
|
+
createComment: (_dangerID: string, comment: string) => Promise<Types.DiscussionNoteSchema | Types.MergeRequestNoteSchema | undefined>;
|
|
18
18
|
createInlineComment: (git: GitDSL, comment: string, path: string, line: number) => Promise<Types.DiscussionSchema>;
|
|
19
|
-
updateInlineComment: (comment: string, id: string) => Promise<Types.
|
|
19
|
+
updateInlineComment: (comment: string, id: string) => Promise<Types.MergeRequestNoteSchema>;
|
|
20
20
|
deleteInlineComment: (id: string) => Promise<boolean>;
|
|
21
21
|
/**
|
|
22
22
|
* Attempts to delete the "main" Danger comment. If the "main" Danger
|
|
23
23
|
* comment has any comments on it then that comment will not be deleted.
|
|
24
24
|
*/
|
|
25
25
|
deleteMainComment: (dangerID: string) => Promise<boolean>;
|
|
26
|
-
|
|
26
|
+
deleteDiscussions: (discussions: Types.DiscussionSchema[]) => Promise<boolean>;
|
|
27
|
+
deleteDiscussion: (discussion: Types.DiscussionSchema) => Promise<boolean>;
|
|
27
28
|
/**
|
|
28
29
|
* Only fetches the discussions where danger owns the top note
|
|
29
30
|
*/
|
|
30
31
|
getDangerDiscussions: (dangerID: string) => Promise<Types.DiscussionSchema[]>;
|
|
31
|
-
|
|
32
|
+
isDangerDiscussionSystemResolved: (discussion: Types.DiscussionSchema) => boolean;
|
|
33
|
+
getDiffNotesFromDiscussions: (discussions: Types.DiscussionSchema[]) => Types.DiscussionNoteSchema[];
|
|
32
34
|
/**
|
|
33
35
|
* Attempts to find the "main" Danger note and should return at most
|
|
34
36
|
* one item. If the "main" Danger note has any comments on it then that
|
|
@@ -38,7 +40,7 @@ declare class GitLab implements Platform {
|
|
|
38
40
|
/**
|
|
39
41
|
* Filters a note to determine if it was created by Danger.
|
|
40
42
|
*/
|
|
41
|
-
getDangerDiscussionNoteFilter: (dangerID: string) => Promise<(note: Types.
|
|
43
|
+
getDangerDiscussionNoteFilter: (dangerID: string) => Promise<(note: Types.DiscussionNoteSchema) => boolean>;
|
|
42
44
|
/**
|
|
43
45
|
* Filters a note to the "main" Danger note. If that note has any
|
|
44
46
|
* comments on it then it will not be found.
|
|
@@ -46,17 +46,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
50
|
exports.gitlabJSONToGitLabDSL = void 0;
|
|
51
|
+
var inlinePositionParser_1 = require("./gitlab/inlinePositionParser");
|
|
60
52
|
var debug_1 = require("../debug");
|
|
61
53
|
var githubIssueTemplate_1 = require("../runner/templates/githubIssueTemplate");
|
|
62
54
|
var d = (0, debug_1.debug)("GitLab");
|
|
@@ -100,13 +92,13 @@ var GitLab = /** @class */ (function () {
|
|
|
100
92
|
}); };
|
|
101
93
|
// TODO: test
|
|
102
94
|
this.getPlatformGitRepresentation = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
103
|
-
var
|
|
95
|
+
var diffs, commits, mappedCommits, modified_files, created_files, deleted_files;
|
|
104
96
|
var _this = this;
|
|
105
97
|
return __generator(this, function (_a) {
|
|
106
98
|
switch (_a.label) {
|
|
107
|
-
case 0: return [4 /*yield*/, this.api.
|
|
99
|
+
case 0: return [4 /*yield*/, this.api.getMergeRequestDiffs()];
|
|
108
100
|
case 1:
|
|
109
|
-
|
|
101
|
+
diffs = _a.sent();
|
|
110
102
|
return [4 /*yield*/, this.api.getMergeRequestCommits()];
|
|
111
103
|
case 2:
|
|
112
104
|
commits = _a.sent();
|
|
@@ -116,12 +108,12 @@ var GitLab = /** @class */ (function () {
|
|
|
116
108
|
author: {
|
|
117
109
|
name: commit.author_name,
|
|
118
110
|
email: commit.author_email,
|
|
119
|
-
date: commit.authored_date
|
|
111
|
+
date: commit.authored_date,
|
|
120
112
|
},
|
|
121
113
|
committer: {
|
|
122
114
|
name: commit.committer_name,
|
|
123
115
|
email: commit.committer_email,
|
|
124
|
-
date: commit.committed_date
|
|
116
|
+
date: commit.committed_date,
|
|
125
117
|
},
|
|
126
118
|
message: commit.message,
|
|
127
119
|
parents: commit.parent_ids,
|
|
@@ -129,11 +121,11 @@ var GitLab = /** @class */ (function () {
|
|
|
129
121
|
tree: null,
|
|
130
122
|
};
|
|
131
123
|
});
|
|
132
|
-
modified_files =
|
|
133
|
-
.filter(function (
|
|
134
|
-
.map(function (
|
|
135
|
-
created_files =
|
|
136
|
-
deleted_files =
|
|
124
|
+
modified_files = diffs
|
|
125
|
+
.filter(function (diff) { return !diff.new_file && !diff.deleted_file; })
|
|
126
|
+
.map(function (diff) { return diff.new_path; });
|
|
127
|
+
created_files = diffs.filter(function (diff) { return diff.new_file; }).map(function (diff) { return diff.new_path; });
|
|
128
|
+
deleted_files = diffs.filter(function (diff) { return diff.deleted_file; }).map(function (diff) { return diff.new_path; });
|
|
137
129
|
return [2 /*return*/, {
|
|
138
130
|
modified_files: modified_files,
|
|
139
131
|
created_files: created_files,
|
|
@@ -144,53 +136,67 @@ var GitLab = /** @class */ (function () {
|
|
|
144
136
|
});
|
|
145
137
|
}); };
|
|
146
138
|
this.getInlineComments = function (dangerID) { return __awaiter(_this, void 0, void 0, function () {
|
|
147
|
-
var dangerUserID;
|
|
139
|
+
var dangerUserID, dangerDiscussions, diffNotes;
|
|
140
|
+
var _this = this;
|
|
148
141
|
return __generator(this, function (_a) {
|
|
149
142
|
switch (_a.label) {
|
|
150
|
-
case 0:
|
|
143
|
+
case 0:
|
|
144
|
+
d("getInlineComments", { dangerID: dangerID });
|
|
145
|
+
return [4 /*yield*/, this.api.getUser()];
|
|
151
146
|
case 1:
|
|
152
147
|
dangerUserID = (_a.sent()).id;
|
|
153
|
-
return [4 /*yield*/, this.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
return [4 /*yield*/, this.getDangerDiscussions(dangerID)
|
|
149
|
+
// Remove system resolved danger discussions to not end up deleting danger inline comments
|
|
150
|
+
// on old versions of the diff. This is preferred as otherwise the discussion ends up in a state where
|
|
151
|
+
// the auto resolve system note can become the first note on the discussion resulting in poor change history on the MR.
|
|
152
|
+
];
|
|
153
|
+
case 2:
|
|
154
|
+
dangerDiscussions = _a.sent();
|
|
155
|
+
// Remove system resolved danger discussions to not end up deleting danger inline comments
|
|
156
|
+
// on old versions of the diff. This is preferred as otherwise the discussion ends up in a state where
|
|
157
|
+
// the auto resolve system note can become the first note on the discussion resulting in poor change history on the MR.
|
|
158
|
+
dangerDiscussions = dangerDiscussions.filter(function (discussion) { return !_this.isDangerDiscussionSystemResolved(discussion); });
|
|
159
|
+
d("getInlineComments found danger discussions", dangerDiscussions);
|
|
160
|
+
diffNotes = this.getDiffNotesFromDiscussions(dangerDiscussions);
|
|
161
|
+
return [2 /*return*/, diffNotes.map(function (note) {
|
|
162
|
+
return {
|
|
163
|
+
id: "".concat(note.id),
|
|
164
|
+
body: note.body,
|
|
165
|
+
ownedByDanger: note.author.id === dangerUserID && note.body.includes(dangerID),
|
|
166
|
+
};
|
|
167
|
+
})];
|
|
161
168
|
}
|
|
162
169
|
});
|
|
163
170
|
}); };
|
|
164
171
|
this.updateOrCreateComment = function (dangerID, newComment) { return __awaiter(_this, void 0, void 0, function () {
|
|
165
172
|
var discussions, firstDiscussion, existingNote, newOrUpdatedNote, notes, note, _i, notes_1, deleteme;
|
|
166
|
-
var _a;
|
|
167
|
-
return __generator(this, function (
|
|
168
|
-
switch (
|
|
173
|
+
var _a, _b, _c;
|
|
174
|
+
return __generator(this, function (_d) {
|
|
175
|
+
switch (_d.label) {
|
|
169
176
|
case 0:
|
|
170
177
|
d("updateOrCreateComment", { dangerID: dangerID, newComment: newComment });
|
|
171
178
|
if (!useThreads()) return [3 /*break*/, 7];
|
|
172
179
|
return [4 /*yield*/, this.getDangerDiscussions(dangerID)];
|
|
173
180
|
case 1:
|
|
174
|
-
discussions =
|
|
181
|
+
discussions = _d.sent();
|
|
182
|
+
d("updateOrCreateComment using threads, discussions", discussions);
|
|
175
183
|
firstDiscussion = discussions.shift();
|
|
176
184
|
existingNote = (_a = firstDiscussion === null || firstDiscussion === void 0 ? void 0 : firstDiscussion.notes) === null || _a === void 0 ? void 0 : _a[0];
|
|
177
|
-
|
|
178
|
-
return [4 /*yield*/, this.deleteNotes(this.reduceNotesFromDiscussions(discussions))]; //delete the rest
|
|
185
|
+
return [4 /*yield*/, this.deleteDiscussions(discussions)];
|
|
179
186
|
case 2:
|
|
180
|
-
|
|
181
|
-
_b.sent(); //delete the rest
|
|
187
|
+
_d.sent();
|
|
182
188
|
newOrUpdatedNote = void 0;
|
|
183
189
|
if (!existingNote) return [3 /*break*/, 4];
|
|
184
190
|
return [4 /*yield*/, this.api.updateMergeRequestNote(existingNote.id, newComment)];
|
|
185
191
|
case 3:
|
|
186
192
|
// update the existing comment
|
|
187
|
-
newOrUpdatedNote =
|
|
193
|
+
newOrUpdatedNote = _d.sent();
|
|
188
194
|
return [3 /*break*/, 6];
|
|
189
|
-
case 4: return [4 /*yield*/, this.
|
|
195
|
+
case 4: return [4 /*yield*/, this.api.createMergeRequestDiscussion(newComment)];
|
|
190
196
|
case 5:
|
|
191
197
|
// create a new comment
|
|
192
|
-
newOrUpdatedNote = _b.sent();
|
|
193
|
-
|
|
198
|
+
newOrUpdatedNote = (_c = (_b = (_d.sent())) === null || _b === void 0 ? void 0 : _b.notes) === null || _c === void 0 ? void 0 : _c[0];
|
|
199
|
+
_d.label = 6;
|
|
194
200
|
case 6:
|
|
195
201
|
if (!newOrUpdatedNote) {
|
|
196
202
|
throw new Error("Could not update or create comment");
|
|
@@ -200,7 +206,8 @@ var GitLab = /** @class */ (function () {
|
|
|
200
206
|
return [2 /*return*/, "".concat(this.api.mergeRequestURL, "#note_").concat(newOrUpdatedNote.id)];
|
|
201
207
|
case 7: return [4 /*yield*/, this.getMainDangerNotes(dangerID)];
|
|
202
208
|
case 8:
|
|
203
|
-
notes =
|
|
209
|
+
notes = _d.sent();
|
|
210
|
+
d("updateOrCreateComment not using threads, main danger notes", notes);
|
|
204
211
|
note = void 0;
|
|
205
212
|
if (!notes.length) return [3 /*break*/, 14];
|
|
206
213
|
return [4 /*yield*/, this.api.updateMergeRequestNote(notes[0].id, newComment)
|
|
@@ -208,9 +215,9 @@ var GitLab = /** @class */ (function () {
|
|
|
208
215
|
];
|
|
209
216
|
case 9:
|
|
210
217
|
// update the first
|
|
211
|
-
note =
|
|
218
|
+
note = _d.sent();
|
|
212
219
|
_i = 0, notes_1 = notes;
|
|
213
|
-
|
|
220
|
+
_d.label = 10;
|
|
214
221
|
case 10:
|
|
215
222
|
if (!(_i < notes_1.length)) return [3 /*break*/, 13];
|
|
216
223
|
deleteme = notes_1[_i];
|
|
@@ -219,8 +226,8 @@ var GitLab = /** @class */ (function () {
|
|
|
219
226
|
}
|
|
220
227
|
return [4 /*yield*/, this.api.deleteMergeRequestNote(deleteme.id)];
|
|
221
228
|
case 11:
|
|
222
|
-
|
|
223
|
-
|
|
229
|
+
_d.sent();
|
|
230
|
+
_d.label = 12;
|
|
224
231
|
case 12:
|
|
225
232
|
_i++;
|
|
226
233
|
return [3 /*break*/, 10];
|
|
@@ -228,8 +235,8 @@ var GitLab = /** @class */ (function () {
|
|
|
228
235
|
case 14: return [4 /*yield*/, this.api.createMergeRequestNote(newComment)];
|
|
229
236
|
case 15:
|
|
230
237
|
// create a new note
|
|
231
|
-
note =
|
|
232
|
-
|
|
238
|
+
note = _d.sent();
|
|
239
|
+
_d.label = 16;
|
|
233
240
|
case 16:
|
|
234
241
|
// create URL from note
|
|
235
242
|
// "https://gitlab.com/group/project/merge_requests/154#note_132143425"
|
|
@@ -251,25 +258,35 @@ var GitLab = /** @class */ (function () {
|
|
|
251
258
|
});
|
|
252
259
|
}); };
|
|
253
260
|
this.createInlineComment = function (git, comment, path, line) { return __awaiter(_this, void 0, void 0, function () {
|
|
254
|
-
var mr;
|
|
255
|
-
|
|
256
|
-
|
|
261
|
+
var structuredDiffForFile, inlinePosition, mr, position;
|
|
262
|
+
var _a, _b;
|
|
263
|
+
return __generator(this, function (_c) {
|
|
264
|
+
switch (_c.label) {
|
|
257
265
|
case 0:
|
|
258
266
|
d("createInlineComment", { git: git, comment: comment, path: path, line: line });
|
|
259
|
-
return [4 /*yield*/,
|
|
267
|
+
return [4 /*yield*/, git.structuredDiffForFile(path)];
|
|
260
268
|
case 1:
|
|
261
|
-
|
|
269
|
+
structuredDiffForFile = _c.sent();
|
|
270
|
+
if (!structuredDiffForFile) {
|
|
271
|
+
return [2 /*return*/, Promise.reject("Unable to find diff for file ".concat(path))];
|
|
272
|
+
}
|
|
273
|
+
inlinePosition = (0, inlinePositionParser_1.inlinePositionParser)(structuredDiffForFile, path, line);
|
|
274
|
+
d("createInlineComment inlinePosition", inlinePosition);
|
|
275
|
+
return [4 /*yield*/, this.api.getMergeRequestInfo()];
|
|
276
|
+
case 2:
|
|
277
|
+
mr = _c.sent();
|
|
278
|
+
position = {
|
|
279
|
+
positionType: "text",
|
|
280
|
+
baseSha: mr.diff_refs.base_sha,
|
|
281
|
+
startSha: mr.diff_refs.start_sha,
|
|
282
|
+
headSha: mr.diff_refs.head_sha,
|
|
283
|
+
oldPath: inlinePosition.pathDiff.oldPath,
|
|
284
|
+
newPath: inlinePosition.pathDiff.newPath,
|
|
285
|
+
oldLine: (_a = inlinePosition.lineDiff.oldLine) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
286
|
+
newLine: (_b = inlinePosition.lineDiff.newLine) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
287
|
+
};
|
|
262
288
|
return [2 /*return*/, this.api.createMergeRequestDiscussion(comment, {
|
|
263
|
-
position:
|
|
264
|
-
position_type: "text",
|
|
265
|
-
base_sha: mr.diff_refs.base_sha,
|
|
266
|
-
start_sha: mr.diff_refs.start_sha,
|
|
267
|
-
head_sha: mr.diff_refs.head_sha,
|
|
268
|
-
old_path: path,
|
|
269
|
-
old_line: undefined,
|
|
270
|
-
new_path: path,
|
|
271
|
-
new_line: line,
|
|
272
|
-
},
|
|
289
|
+
position: position,
|
|
273
290
|
})];
|
|
274
291
|
}
|
|
275
292
|
});
|
|
@@ -315,7 +332,7 @@ var GitLab = /** @class */ (function () {
|
|
|
315
332
|
return [4 /*yield*/, this.getDangerDiscussions(dangerID)];
|
|
316
333
|
case 1:
|
|
317
334
|
discussions = _a.sent();
|
|
318
|
-
return [4 /*yield*/, this.
|
|
335
|
+
return [4 /*yield*/, this.deleteDiscussions(discussions)];
|
|
319
336
|
case 2: return [2 /*return*/, _a.sent()];
|
|
320
337
|
case 3: return [4 /*yield*/, this.getMainDangerNotes(dangerID)];
|
|
321
338
|
case 4:
|
|
@@ -337,25 +354,49 @@ var GitLab = /** @class */ (function () {
|
|
|
337
354
|
}
|
|
338
355
|
});
|
|
339
356
|
}); };
|
|
340
|
-
this.
|
|
341
|
-
var _i,
|
|
357
|
+
this.deleteDiscussions = function (discussions) { return __awaiter(_this, void 0, void 0, function () {
|
|
358
|
+
var _i, discussions_1, discussion;
|
|
342
359
|
return __generator(this, function (_a) {
|
|
343
360
|
switch (_a.label) {
|
|
344
361
|
case 0:
|
|
345
|
-
|
|
362
|
+
d("deleteDiscussions", { length: discussions.length });
|
|
363
|
+
_i = 0, discussions_1 = discussions;
|
|
346
364
|
_a.label = 1;
|
|
347
365
|
case 1:
|
|
348
|
-
if (!(_i <
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
return [4 /*yield*/, this.api.deleteMergeRequestNote(note.id)];
|
|
366
|
+
if (!(_i < discussions_1.length)) return [3 /*break*/, 4];
|
|
367
|
+
discussion = discussions_1[_i];
|
|
368
|
+
return [4 /*yield*/, this.deleteDiscussion(discussion)];
|
|
352
369
|
case 2:
|
|
353
370
|
_a.sent();
|
|
354
371
|
_a.label = 3;
|
|
355
372
|
case 3:
|
|
356
373
|
_i++;
|
|
357
374
|
return [3 /*break*/, 1];
|
|
358
|
-
case 4: return [2 /*return*/,
|
|
375
|
+
case 4: return [2 /*return*/, discussions.length > 0];
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
}); };
|
|
379
|
+
this.deleteDiscussion = function (discussion) { return __awaiter(_this, void 0, void 0, function () {
|
|
380
|
+
var discussionNotes, _i, discussionNotes_1, discussionNote;
|
|
381
|
+
var _a;
|
|
382
|
+
return __generator(this, function (_b) {
|
|
383
|
+
switch (_b.label) {
|
|
384
|
+
case 0:
|
|
385
|
+
d("deleteDiscussion", { discussionId: discussion.id });
|
|
386
|
+
discussionNotes = (_a = discussion.notes) !== null && _a !== void 0 ? _a : [];
|
|
387
|
+
_i = 0, discussionNotes_1 = discussionNotes;
|
|
388
|
+
_b.label = 1;
|
|
389
|
+
case 1:
|
|
390
|
+
if (!(_i < discussionNotes_1.length)) return [3 /*break*/, 4];
|
|
391
|
+
discussionNote = discussionNotes_1[_i];
|
|
392
|
+
return [4 /*yield*/, this.api.deleteMergeRequestNote(discussionNote.id)];
|
|
393
|
+
case 2:
|
|
394
|
+
_b.sent();
|
|
395
|
+
_b.label = 3;
|
|
396
|
+
case 3:
|
|
397
|
+
_i++;
|
|
398
|
+
return [3 /*break*/, 1];
|
|
399
|
+
case 4: return [2 /*return*/, discussionNotes.length > 0];
|
|
359
400
|
}
|
|
360
401
|
});
|
|
361
402
|
}); };
|
|
@@ -379,12 +420,30 @@ var GitLab = /** @class */ (function () {
|
|
|
379
420
|
}
|
|
380
421
|
});
|
|
381
422
|
}); };
|
|
382
|
-
this.
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
423
|
+
this.isDangerDiscussionSystemResolved = function (discussion) {
|
|
424
|
+
var notes = discussion.notes;
|
|
425
|
+
if (!notes) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
var dangerNote = notes[0];
|
|
429
|
+
if (!dangerNote || !dangerNote.resolved) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
// Check for a system note that resolved it
|
|
433
|
+
return notes.some(function (note) {
|
|
434
|
+
return note.system === true;
|
|
435
|
+
});
|
|
436
|
+
};
|
|
437
|
+
this.getDiffNotesFromDiscussions = function (discussions) {
|
|
438
|
+
var diffNotes = discussions.map(function (discussion) {
|
|
439
|
+
var _a;
|
|
440
|
+
var note = (_a = discussion.notes) === null || _a === void 0 ? void 0 : _a[0];
|
|
441
|
+
if (!note || note.type != "DiffNote") {
|
|
442
|
+
return undefined;
|
|
443
|
+
}
|
|
444
|
+
return note;
|
|
445
|
+
});
|
|
446
|
+
return diffNotes.filter(Boolean);
|
|
388
447
|
};
|
|
389
448
|
/**
|
|
390
449
|
* Attempts to find the "main" Danger note and should return at most
|