Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions .github/workflows/scripts/create_address_commit_comments_issues
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,25 @@ is_core_contributor() {

# Updates two indexed arrays (commit_keys and commit_counts) to simulate a map.
#
# $1 - Commit SHA (the key)
# $2 - Comment URL (the link)
# $1 - Full comment object (JSON)
update_commit_map() {
local key="$1"
local link="$2"
local comment="$1"
local key=$(echo "$comment" | jq -r '.commit_id')
local link=$(echo "$comment" | jq -r '.html_url')
local body=$(echo "$comment" | jq -r '.body')
local line=$(echo "$comment" | jq -r '.line')
local path=$(echo "$comment" | jq -r '.path')
local found=0
local i=0

local startLine=$(( line - 3 ))
local endLine=$(( line + 3 ))
local code_snippet="https://github.com/stdlib-js/stdlib/blob/${key}/${path}#L${startLine}-L${endLine}"

for existing in "${commit_keys[@]}"; do
if [ "$existing" = "$key" ]; then
commit_counts[i]=$(( commit_counts[i] + 1 ))
# Append the comment URL (on a new bullet) to the existing list:
commit_links[i]="${commit_links[i]}"$'\n'"- ${link}"
commit_comments[i]="${commit_comments[i]}"$'\n\n'"- ${link}"$'\n\n'" > **Line ${line}**: ${body}"$'\n\n'" ${code_snippet}"
found=1
break
fi
Expand All @@ -255,7 +261,7 @@ update_commit_map() {
if [ "$found" -eq 0 ]; then
commit_keys+=("$key")
commit_counts+=("1")
commit_links+=("- ${link}")
commit_comments+=("- ${link}"$'\n\n'" > **Line ${line}**: ${body}"$'\n\n'" ${code_snippet}")
fi
}

Expand Down Expand Up @@ -339,12 +345,12 @@ main() {

commit_keys=()
commit_counts=()
commit_links=()
commit_comments=()

for comment in "${all_comments[@]}"; do
# Extract the comment body:
local comment_body
comment_body=$(echo "$comment" | jq -r '.body')
local comment_body=$(echo "$comment" | jq -r '.body')
local comment_line=$(echo "$comment" | jq -r '.line')

# Check if the comment body contains '@stdlib-bot':
if [[ "$comment_body" == *"@stdlib-bot"* ]]; then
Expand All @@ -357,10 +363,7 @@ main() {
local commit_sha
commit_sha=$(echo "$comment" | jq -r '.commit_id')
if [ -n "$commit_sha" ]; then
# Extract the comment URL:
local comment_url
comment_url=$(echo "$comment" | jq -r '.html_url')
update_commit_map "$commit_sha" "$comment_url"
update_commit_map "$comment"
fi
else
echo "Skipping comment by non-core contributor: ${comment_author}" >&2
Expand All @@ -373,7 +376,7 @@ main() {
for idx in $(seq 0 $(( ${#commit_keys[@]} - 1 ))); do
local commit_sha="${commit_keys[$idx]}"
local count="${commit_counts[$idx]}"
local links="${commit_links[$idx]}"
local comments="${commit_comments[$idx]}"

# Generate a short SHA (first 7 characters):
local short_sha=${commit_sha:0:7}
Expand All @@ -385,7 +388,7 @@ main() {

**Comments:**

${links}
${comments}

Interested in helping improve the project? If you are, the comment linked to above has **${count}** comment(s) from core contributors that could use your attention.

Expand Down