Skip to content

Commit fbb4bd5

Browse files
committed
handle_comment: Handle renamed repositories
1 parent 1076355 commit fbb4bd5

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

unknown-words.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ handle_comment() {
773773
git reset --hard
774774

775775
summary_url=$(echo "$trigger" | perl -ne '
776-
next unless m{($ENV{GITHUB_SERVER_URL}/$ENV{GITHUB_REPOSITORY}/actions/runs/\d+(?:/attempts/\d+|)(?:#\S+|))};
776+
next unless m{($ENV{GITHUB_SERVER_URL}/[^/]+/[^/]+/actions/runs/\d+(?:/attempts/\d+|)(?:#\S+|))};
777777
print $1;
778778
')
779779
comment_url=$(echo "$trigger" | comment_api_url)
@@ -842,6 +842,19 @@ handle_comment() {
842842
rm "$instructions"
843843
update_note="per $(comment_url_to_html_url "$comment_url")"
844844
elif [ -n "$summary_url" ]; then
845+
summary_url_repo=$(echo "$summary_url" | perl -ne '
846+
next unless m{$ENV{GITHUB_SERVER_URL}/([^/]+/[^/]+)/actions/runs/\d+(?:/attempts/\d+|)(?:#\S+|)};
847+
print $1;
848+
')
849+
if [ "$summary_url_repo" != "$GITHUB_REPOSITORY" ]; then
850+
pull_url=$(jq -r '.issue.html_url // empty' "$GITHUB_EVENT_PATH")
851+
if [ -n "$pull_url" ]; then
852+
see_checks_url="Look in the [checks tab]($pull_url/checks) for the latest check-spelling report."
853+
else
854+
see_checks_url=''
855+
fi
856+
confused_comment "$trigger_comment_url" "Found a GitHub summary for repo $b$summary_url_repo$b but expected repo $b$GITHUB_REPOSITORY$b. This could be because the repository was moved or renamed, or it could just be from the wrong repository. $see_checks_url"
857+
fi
845858
if [ -n "$INPUT_REPORT_TITLE_SUFFIX" ]; then
846859
title_suffix_re='.*'"$("$quote_meta" "$INPUT_REPORT_TITLE_SUFFIX")"
847860
fi

0 commit comments

Comments
 (0)