@sentry/junior-github 0.278.0 → 0.279.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/dist/index.js +184 -109
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5284,8 +5284,12 @@ if [ -z "$repository_hooks_dir" ]; then
|
|
|
5284
5284
|
repository_hooks_dir="$git_common_dir/hooks"
|
|
5285
5285
|
fi
|
|
5286
5286
|
fi
|
|
5287
|
-
if [ -n "$repository_hooks_dir" ] && [ -x "$repository_hooks_dir/${name}" ]
|
|
5288
|
-
|
|
5287
|
+
if [ -n "$repository_hooks_dir" ] && [ -x "$repository_hooks_dir/${name}" ]; then
|
|
5288
|
+
repository_hooks_real=$(CDPATH='' cd -- "$repository_hooks_dir" && pwd -P) || repository_hooks_real=""
|
|
5289
|
+
junior_hooks_real=$(CDPATH='' cd -- "\${0%/*}" && pwd -P) || junior_hooks_real=""
|
|
5290
|
+
if [ "$repository_hooks_real" != "$junior_hooks_real" ]; then
|
|
5291
|
+
repository_hook="$repository_hooks_dir/${name}"
|
|
5292
|
+
fi
|
|
5289
5293
|
fi`;
|
|
5290
5294
|
}
|
|
5291
5295
|
function repositoryHook(name) {
|
|
@@ -5298,14 +5302,100 @@ if [ -n "$repository_hook" ]; then
|
|
|
5298
5302
|
fi
|
|
5299
5303
|
`;
|
|
5300
5304
|
}
|
|
5305
|
+
var SET_COAUTHOR_TRAILERS_AWK = String.raw`
|
|
5306
|
+
function blank(line) { return line ~ /^[[:space:]]*$/ }
|
|
5307
|
+
function comment(line) { return substr(line, 1, 1) == "#" }
|
|
5308
|
+
function trailer(line) {
|
|
5309
|
+
return coauthor(line) || line ~ /^[A-Z][[:alnum:]-]*: ./ || line ~ /^\(cherry picked from commit [0-9a-f]+\)$/
|
|
5310
|
+
}
|
|
5311
|
+
function coauthor(line) { return tolower(line) ~ /^co-authored-by: / }
|
|
5312
|
+
{ lines[NR] = $0 }
|
|
5313
|
+
END {
|
|
5314
|
+
last = NR
|
|
5315
|
+
while (last > 0 && (blank(lines[last]) || comment(lines[last]))) last--
|
|
5316
|
+
count = 0
|
|
5317
|
+
i = 1
|
|
5318
|
+
while (i <= last) {
|
|
5319
|
+
count++
|
|
5320
|
+
gap[count] = i
|
|
5321
|
+
while (blank(lines[i])) i++
|
|
5322
|
+
first[count] = i
|
|
5323
|
+
while (i <= last && !blank(lines[i])) i++
|
|
5324
|
+
final[count] = i - 1
|
|
5325
|
+
}
|
|
5326
|
+
subject = 0
|
|
5327
|
+
content_count = 0
|
|
5328
|
+
for (p = 1; p <= count; p++) {
|
|
5329
|
+
content = 0
|
|
5330
|
+
trailers = 1
|
|
5331
|
+
for (j = first[p]; j <= final[p]; j++) {
|
|
5332
|
+
if (comment(lines[j])) continue
|
|
5333
|
+
content = 1
|
|
5334
|
+
if (!trailer(lines[j])) trailers = 0
|
|
5335
|
+
}
|
|
5336
|
+
if (content && !subject) subject = p
|
|
5337
|
+
trailer_paragraph[p] = content && trailers
|
|
5338
|
+
kept[p] = 0
|
|
5339
|
+
kept_content[p] = 0
|
|
5340
|
+
for (j = first[p]; j <= final[p]; j++) {
|
|
5341
|
+
drop[j] = trailer_paragraph[p] && coauthor(lines[j])
|
|
5342
|
+
if (drop[j]) continue
|
|
5343
|
+
kept[p]++
|
|
5344
|
+
if (!comment(lines[j])) kept_content[p]++
|
|
5345
|
+
}
|
|
5346
|
+
if (kept_content[p]) content_count++
|
|
5347
|
+
}
|
|
5348
|
+
if (ENVIRON["JUNIOR_COAUTHOR_LIST"] != "") {
|
|
5349
|
+
for (j = 1; j <= last; j++) {
|
|
5350
|
+
if (!drop[j]) continue
|
|
5351
|
+
line = lines[j]
|
|
5352
|
+
sub(/^[^:]*:[[:space:]]*/, "", line)
|
|
5353
|
+
print "Co-Authored-By: " line
|
|
5354
|
+
}
|
|
5355
|
+
exit
|
|
5356
|
+
}
|
|
5357
|
+
last_paragraph = 0
|
|
5358
|
+
for (p = 1; p <= count; p++) {
|
|
5359
|
+
if (!kept[p]) continue
|
|
5360
|
+
for (j = gap[p]; j < first[p]; j++) print lines[j]
|
|
5361
|
+
for (j = first[p]; j <= final[p]; j++) if (!drop[j]) print lines[j]
|
|
5362
|
+
last_paragraph = p
|
|
5363
|
+
}
|
|
5364
|
+
if (content_count) {
|
|
5365
|
+
inline = last_paragraph != subject && trailer_paragraph[last_paragraph] && kept_content[last_paragraph]
|
|
5366
|
+
bot = tolower(ENVIRON["JUNIOR_GIT_AUTHOR_EMAIL"])
|
|
5367
|
+
n = split(ENVIRON["JUNIOR_COAUTHOR_TRAILERS"], wanted, "\n")
|
|
5368
|
+
for (k = 1; k <= n; k++) {
|
|
5369
|
+
line = wanted[k]
|
|
5370
|
+
if (line !~ /^Co-Authored-By: [^<>]+ <[^<>[:space:]]+@[^<>[:space:]]+>$/) continue
|
|
5371
|
+
email = tolower(line)
|
|
5372
|
+
sub(/^[^<]*</, "", email)
|
|
5373
|
+
sub(/>$/, "", email)
|
|
5374
|
+
if (email == bot || seen[email]++) continue
|
|
5375
|
+
if (!inline) print ""
|
|
5376
|
+
inline = 1
|
|
5377
|
+
print line
|
|
5378
|
+
}
|
|
5379
|
+
}
|
|
5380
|
+
for (j = last + 1; j <= NR; j++) print lines[j]
|
|
5381
|
+
}
|
|
5382
|
+
`;
|
|
5301
5383
|
function prepareCommitMsgHook() {
|
|
5302
|
-
return `#!/
|
|
5384
|
+
return `#!/bin/sh
|
|
5303
5385
|
set -eu
|
|
5304
5386
|
|
|
5305
|
-
|
|
5306
|
-
if [ -z "$message_file" ]; then
|
|
5387
|
+
if [ "$#" -lt 1 ] || [ -z "$1" ]; then
|
|
5307
5388
|
exit 1
|
|
5308
5389
|
fi
|
|
5390
|
+
message_file=$1
|
|
5391
|
+
commit_source=""
|
|
5392
|
+
if [ "$#" -ge 2 ]; then
|
|
5393
|
+
commit_source=$2
|
|
5394
|
+
fi
|
|
5395
|
+
source_commit=""
|
|
5396
|
+
if [ "$#" -ge 3 ]; then
|
|
5397
|
+
source_commit=$3
|
|
5398
|
+
fi
|
|
5309
5399
|
|
|
5310
5400
|
# Run the repository hook first so Junior's trailers stay final.
|
|
5311
5401
|
${findRepositoryHook("prepare-commit-msg")}
|
|
@@ -5318,124 +5408,109 @@ if [ -z "\${JUNIOR_GIT_AUTHOR_NAME:-}" ] || [ -z "\${JUNIOR_GIT_AUTHOR_EMAIL:-}"
|
|
|
5318
5408
|
exit 1
|
|
5319
5409
|
fi
|
|
5320
5410
|
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
exit 1
|
|
5324
|
-
fi
|
|
5411
|
+
nl='
|
|
5412
|
+
'
|
|
5325
5413
|
|
|
5326
|
-
#
|
|
5327
|
-
#
|
|
5328
|
-
#
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5414
|
+
# Commits whose changes this commit replaces. Their co-authors stay
|
|
5415
|
+
# credited, so an amend, rebase, cherry-pick, or squash keeps them even when
|
|
5416
|
+
# the current run has other human actors or none.
|
|
5417
|
+
rewritten_commits=""
|
|
5418
|
+
add_rewritten_commit() {
|
|
5419
|
+
if [ -n "$1" ]; then
|
|
5420
|
+
rewritten_commits="$rewritten_commits $1"
|
|
5421
|
+
fi
|
|
5332
5422
|
}
|
|
5333
5423
|
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
add_trailer "$actor_trailer"
|
|
5338
|
-
fi
|
|
5339
|
-
done <<< "$JUNIOR_GIT_ACTOR_COAUTHOR_TRAILERS"
|
|
5424
|
+
# \`--amend\`, \`-c\`, \`-C\`, and rebase \`reword\`.
|
|
5425
|
+
if [ "$commit_source" = "commit" ]; then
|
|
5426
|
+
add_rewritten_commit "$source_commit"
|
|
5340
5427
|
fi
|
|
5341
5428
|
|
|
5342
|
-
#
|
|
5343
|
-
# from the
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
line--
|
|
5352
|
-
}
|
|
5353
|
-
start = line
|
|
5354
|
-
while (start > 0 && lines[start] != "") {
|
|
5355
|
-
start--
|
|
5356
|
-
}
|
|
5357
|
-
valid = line > 0
|
|
5358
|
-
for (i = start + 1; valid && i <= line; i++) {
|
|
5359
|
-
if (lines[i] !~ /^[[:alnum:]-]+: .+/) {
|
|
5360
|
-
valid = 0
|
|
5361
|
-
}
|
|
5362
|
-
}
|
|
5363
|
-
if (!valid) {
|
|
5364
|
-
for (i = 1; i <= NR; i++) {
|
|
5365
|
-
print lines[i]
|
|
5366
|
-
}
|
|
5367
|
-
exit 0
|
|
5368
|
-
}
|
|
5369
|
-
kept = 0
|
|
5370
|
-
for (i = start + 1; i <= line; i++) {
|
|
5371
|
-
if (tolower(lines[i]) !~ /^co-authored-by: /) {
|
|
5372
|
-
kept++
|
|
5373
|
-
}
|
|
5374
|
-
}
|
|
5375
|
-
before = kept > 0 ? start : start - 1
|
|
5376
|
-
for (i = 1; i <= before; i++) {
|
|
5377
|
-
print lines[i]
|
|
5378
|
-
}
|
|
5379
|
-
for (i = start + 1; i <= line; i++) {
|
|
5380
|
-
if (tolower(lines[i]) !~ /^co-authored-by: /) {
|
|
5381
|
-
print lines[i]
|
|
5382
|
-
}
|
|
5383
|
-
}
|
|
5384
|
-
}
|
|
5385
|
-
' "$message_file" > "$tmp_file"
|
|
5386
|
-
cat "$tmp_file" > "$message_file"
|
|
5387
|
-
|
|
5388
|
-
final_trailer_block=$(awk '
|
|
5389
|
-
{ lines[NR] = $0 }
|
|
5390
|
-
END {
|
|
5391
|
-
line = NR
|
|
5392
|
-
while (line > 0 && lines[line] == "") {
|
|
5393
|
-
line--
|
|
5394
|
-
}
|
|
5395
|
-
if (line == 0) {
|
|
5396
|
-
exit 0
|
|
5397
|
-
}
|
|
5398
|
-
start = line
|
|
5399
|
-
while (start > 0 && lines[start] != "") {
|
|
5400
|
-
start--
|
|
5401
|
-
}
|
|
5402
|
-
for (i = start + 1; i <= line; i++) {
|
|
5403
|
-
if (lines[i] !~ /^[[:alnum:]-]+: .+/) {
|
|
5404
|
-
exit 0
|
|
5405
|
-
}
|
|
5406
|
-
}
|
|
5407
|
-
for (i = start + 1; i <= line; i++) {
|
|
5408
|
-
print lines[i]
|
|
5409
|
-
}
|
|
5410
|
-
}
|
|
5411
|
-
' "$message_file")
|
|
5429
|
+
# \`--amend -m\` and \`--amend -F\` give the "message" source, so read the
|
|
5430
|
+
# flag from the parent \`git commit\` process.
|
|
5431
|
+
parent_args=""
|
|
5432
|
+
if [ -r "/proc/$PPID/cmdline" ]; then
|
|
5433
|
+
parent_args=$(tr '\\000' '\\n' < "/proc/$PPID/cmdline") || parent_args=""
|
|
5434
|
+
fi
|
|
5435
|
+
case "$nl$parent_args$nl" in
|
|
5436
|
+
*"$nl--amend$nl"*) add_rewritten_commit HEAD ;;
|
|
5437
|
+
esac
|
|
5412
5438
|
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5439
|
+
git_dir=$(git rev-parse --git-dir 2>/dev/null) || git_dir=""
|
|
5440
|
+
if [ -n "$git_dir" ]; then
|
|
5441
|
+
# Each rebase \`pick\` and each \`git cherry-pick\`.
|
|
5442
|
+
if git rev-parse -q --verify CHERRY_PICK_HEAD >/dev/null 2>&1; then
|
|
5443
|
+
add_rewritten_commit CHERRY_PICK_HEAD
|
|
5417
5444
|
fi
|
|
5418
|
-
}
|
|
5419
5445
|
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5446
|
+
if [ -f "$git_dir/rebase-merge/done" ]; then
|
|
5447
|
+
# A rebase step that stopped on a conflict. An \`edit\` stop writes
|
|
5448
|
+
# \`amend\`, and a new commit there replaces no commit.
|
|
5449
|
+
if [ ! -f "$git_dir/rebase-merge/amend" ] && git rev-parse -q --verify REBASE_HEAD >/dev/null 2>&1; then
|
|
5450
|
+
add_rewritten_commit REBASE_HEAD
|
|
5451
|
+
fi
|
|
5452
|
+
# A \`fixup\` or \`squash\` folds its commit into HEAD. A rebased merge
|
|
5453
|
+
# reuses the commit in \`merge -C\`.
|
|
5454
|
+
rebase_step=$(tail -n 1 "$git_dir/rebase-merge/done")
|
|
5455
|
+
case "$rebase_step" in
|
|
5456
|
+
f\\ *|fixup\\ *|s\\ *|squash\\ *) add_rewritten_commit HEAD ;;
|
|
5457
|
+
esac
|
|
5458
|
+
case "$rebase_step" in
|
|
5459
|
+
f\\ *|fixup\\ *|s\\ *|squash\\ *|m\\ *|merge\\ *)
|
|
5460
|
+
step_commit=$(printf '%s\\n' "$rebase_step" | sed -n 's/^[a-z]* \\(-[Cc] \\)\\{0,1\\}\\([0-9a-f]\\{40,64\\}\\).*/\\2/p')
|
|
5461
|
+
add_rewritten_commit "$step_commit"
|
|
5462
|
+
;;
|
|
5463
|
+
esac
|
|
5423
5464
|
fi
|
|
5424
|
-
done <<< "$desired_trailers"
|
|
5425
5465
|
|
|
5426
|
-
|
|
5427
|
-
|
|
5466
|
+
# \`git merge --squash\` lists the squashed commits in SQUASH_MSG.
|
|
5467
|
+
if [ "$commit_source" = "squash" ] && [ -f "$git_dir/SQUASH_MSG" ]; then
|
|
5468
|
+
squashed_commits=$(sed -n 's/^commit \\([0-9a-f]\\{40,64\\}\\).*/\\1/p' "$git_dir/SQUASH_MSG")
|
|
5469
|
+
for squashed_commit in $squashed_commits; do
|
|
5470
|
+
add_rewritten_commit "$squashed_commit"
|
|
5471
|
+
done
|
|
5472
|
+
fi
|
|
5428
5473
|
fi
|
|
5429
5474
|
|
|
5430
|
-
|
|
5431
|
-
|
|
5475
|
+
# A rewrite keeps the author of the commit it replaces, and Git passes that
|
|
5476
|
+
# author to this hook.
|
|
5477
|
+
if [ "\${GIT_AUTHOR_NAME:-}" != "$JUNIOR_GIT_AUTHOR_NAME" ] || [ "\${GIT_AUTHOR_EMAIL:-}" != "$JUNIOR_GIT_AUTHOR_EMAIL" ]; then
|
|
5478
|
+
kept_author=""
|
|
5479
|
+
for rewritten_commit in $rewritten_commits; do
|
|
5480
|
+
rewritten_author=$(git show -s --format='%an%n%ae' "$rewritten_commit" -- 2>/dev/null) || continue
|
|
5481
|
+
if [ "$rewritten_author" = "\${GIT_AUTHOR_NAME:-}$nl\${GIT_AUTHOR_EMAIL:-}" ]; then
|
|
5482
|
+
kept_author=$rewritten_author
|
|
5483
|
+
fi
|
|
5484
|
+
done
|
|
5485
|
+
if [ -z "$kept_author" ]; then
|
|
5486
|
+
echo "GitHub plugin internal error: Git author was not set to the configured identity. Do not override Git author manually; report this configuration error." >&2
|
|
5487
|
+
exit 1
|
|
5488
|
+
fi
|
|
5432
5489
|
fi
|
|
5433
5490
|
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5491
|
+
set_coauthor_trailers() {
|
|
5492
|
+
awk '${SET_COAUTHOR_TRAILERS_AWK}' "$@"
|
|
5493
|
+
}
|
|
5494
|
+
|
|
5495
|
+
# Existing co-authors first, then the host-derived human run actors.
|
|
5496
|
+
coauthor_trailers=""
|
|
5497
|
+
for rewritten_commit in $rewritten_commits; do
|
|
5498
|
+
rewritten_message=$(git show -s --format=%B "$rewritten_commit" -- 2>/dev/null) || continue
|
|
5499
|
+
coauthors=$(
|
|
5500
|
+
JUNIOR_COAUTHOR_LIST=1
|
|
5501
|
+
export JUNIOR_COAUTHOR_LIST
|
|
5502
|
+
printf '%s\\n' "$rewritten_message" | set_coauthor_trailers
|
|
5503
|
+
)
|
|
5504
|
+
coauthor_trailers="$coauthor_trailers$coauthors$nl"
|
|
5505
|
+
done
|
|
5506
|
+
coauthor_trailers="$coauthor_trailers\${JUNIOR_GIT_ACTOR_COAUTHOR_TRAILERS:-}"
|
|
5507
|
+
|
|
5508
|
+
message=$(
|
|
5509
|
+
JUNIOR_COAUTHOR_TRAILERS=$coauthor_trailers
|
|
5510
|
+
export JUNIOR_COAUTHOR_TRAILERS
|
|
5511
|
+
set_coauthor_trailers "$message_file"
|
|
5512
|
+
)
|
|
5513
|
+
printf '%s\\n' "$message" > "$message_file"
|
|
5439
5514
|
`;
|
|
5440
5515
|
}
|
|
5441
5516
|
var PREPARE_GIT_SCRIPT = `set -eu
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.279.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
33
|
"marked": "^18.1.2",
|
|
34
34
|
"zod": "^4.5.4",
|
|
35
|
-
"@sentry/junior-plugin-api": "0.
|
|
35
|
+
"@sentry/junior-plugin-api": "0.279.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@oxlint/plugins": "1.79.0",
|