@sentry/junior-github 0.67.0 → 0.67.2
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/index.js +24 -11
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -13,18 +13,33 @@ function cleanIdentityPart(value) {
|
|
|
13
13
|
.trim();
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
function isSlackUserId(value) {
|
|
17
|
+
return /^[UW][A-Z0-9]{5,}$/.test(value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function requesterDisplayName(value, requester) {
|
|
21
|
+
const name = cleanIdentityPart(value);
|
|
22
|
+
if (
|
|
23
|
+
!name ||
|
|
24
|
+
name.toLowerCase() === "unknown" ||
|
|
25
|
+
name === cleanIdentityPart(requester?.userId)
|
|
26
|
+
) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return isSlackUserId(name) ? undefined : name;
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
function requesterName(requester) {
|
|
17
33
|
return (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
cleanIdentityPart(requester?.userId) ||
|
|
34
|
+
requesterDisplayName(requester?.fullName, requester) ||
|
|
35
|
+
requesterDisplayName(requester?.userName, requester) ||
|
|
21
36
|
undefined
|
|
22
37
|
);
|
|
23
38
|
}
|
|
24
39
|
|
|
25
40
|
function requesterEmail(requester) {
|
|
26
41
|
const email = cleanIdentityPart(requester?.email);
|
|
27
|
-
return
|
|
42
|
+
return /^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(email) ? email : undefined;
|
|
28
43
|
}
|
|
29
44
|
|
|
30
45
|
function isGitCommitCommand(command) {
|
|
@@ -156,9 +171,10 @@ export function githubPlugin(options = {}) {
|
|
|
156
171
|
return;
|
|
157
172
|
}
|
|
158
173
|
const coauthorName = requesterName(ctx.requester);
|
|
159
|
-
|
|
174
|
+
const coauthorEmail = requesterEmail(ctx.requester);
|
|
175
|
+
if ((!coauthorName || !coauthorEmail) && isGitCommitCommand(command)) {
|
|
160
176
|
ctx.decision.deny(
|
|
161
|
-
"Junior GitHub plugin could not determine requester
|
|
177
|
+
"Junior GitHub plugin could not determine a resolved requester name and email for commit attribution. This is an internal request-context error; do not set coauthor env vars manually.",
|
|
162
178
|
);
|
|
163
179
|
return;
|
|
164
180
|
}
|
|
@@ -168,12 +184,9 @@ export function githubPlugin(options = {}) {
|
|
|
168
184
|
ctx.env.set("GIT_COMMITTER_EMAIL", botEmail);
|
|
169
185
|
ctx.env.set("JUNIOR_GIT_AUTHOR_NAME", botName);
|
|
170
186
|
ctx.env.set("JUNIOR_GIT_AUTHOR_EMAIL", botEmail);
|
|
171
|
-
if (coauthorName) {
|
|
187
|
+
if (coauthorName && coauthorEmail) {
|
|
172
188
|
ctx.env.set("JUNIOR_GIT_COAUTHOR_NAME", coauthorName);
|
|
173
|
-
ctx.env.set(
|
|
174
|
-
"JUNIOR_GIT_COAUTHOR_EMAIL",
|
|
175
|
-
requesterEmail(ctx.requester),
|
|
176
|
-
);
|
|
189
|
+
ctx.env.set("JUNIOR_GIT_COAUTHOR_EMAIL", coauthorEmail);
|
|
177
190
|
}
|
|
178
191
|
},
|
|
179
192
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.67.
|
|
3
|
+
"version": "0.67.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"SETUP.md"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@sentry/junior-plugin-api": "0.67.
|
|
27
|
+
"@sentry/junior-plugin-api": "0.67.2"
|
|
28
28
|
}
|
|
29
29
|
}
|