Skip to content

fix: update logic for splitting sentences #3089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
21 changes: 16 additions & 5 deletions .github/workflows/scripts/generate_pr_commit_message
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MVARUNREDDY8203 Can you explain why this PR is changing this file?

Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ github_api() {
curl -s "${headers[@]}" "$GITHUB_API_URL$endpoint"
;;
POST)
# For POST requests, always set the Content-Type header>
# For POST requests, always set the Content-Type header:
headers+=("-H" "Content-Type: application/json")

# If data is provided, include it in the request:
Expand Down Expand Up @@ -156,13 +156,22 @@ main() {
pr_commits=$(github_api "GET" "/repos/$REPO_OWNER/$REPO_NAME/pulls/$pr_number/commits")

# Extract co-authors from commit messages:
co_authors=$(echo "$pr_commits" | jq -r '.[].commit.message' | grep -Eio 'Co-authored-by:.*' | sort -u)
processed_co_authors=""
while IFS= read -r co_author_line; do
# Skip empty lines:
if [ -z "$co_author_line" ]; then
continue
fi
name_email=$(echo "$co_author_line" | sed -E 's/Co-authored-by:[[:space:]]*(.*)/\1/')
name=$(echo "$name_email" | sed -E 's/^(.*)<.*>$/\1/' | xargs)
email=$(echo "$name_email" | sed -E 's/^.*<(.*)>$/\1/' | xargs)
resolved_author=$(resolve_name_email "$name" "$email")

# Skip if the resolved author matches the resolved PR author:
if [ "$resolved_author" == "$pr_author_resolved" ]; then
continue
fi
processed_co_authors+="Co-authored-by: $resolved_author"$'\n'
done <<< "$co_authors"

Expand Down Expand Up @@ -195,11 +204,13 @@ main() {
# Remove any empty lines and duplicates:
commit_authors=$(echo "$commit_authors" | sort -u | sed '/^$/d')

# Prefix with 'Co-authored-by: ':
commit_authors_formatted=$(echo "$commit_authors" | sed 's/^/Co-authored-by: /' | sort -u)
# Prefix with 'Co-authored-by: ' if not empty:
if [ -n "$commit_authors" ]; then
commit_authors=$(echo "$commit_authors" | sed 's/^/Co-authored-by: /' | sort -u)
fi

# Combine co-authors and commit authors:
all_co_authors=$(echo -e "$co_authors\n$commit_authors_formatted" | sort -u | sed '/^$/d')
# Combine co-authors and commit authors, removing empty lines:
all_co_authors=$(echo -e "$processed_co_authors\n$commit_authors" | sed '/^\s*$/d' | sort -u)

# Extract 'Signed-off-by' lines from commits:
signed_off_bys=$(echo "$pr_commits" | jq -r '.[].commit.message' | grep -Eio 'Signed-off-by:.*' | sort -u)
Expand Down
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/nlp/sentencize/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function isEndOfSentence( tokens, i ) {
if (
( token === '!' || token === '?' ) &&
!RE_PREFIXES.test( tokens[ im1 ] ) &&
!RE_SUFFIXES.test( tokens[ ip1 ] )
!RE_SUFFIXES.test( tokens[ ip1 ] ) && !(tokens[ip1] === '"' ) && !(tokens[ip1] === "'")
) {
return true;
}
Expand Down
Loading