@@ -56,7 +56,7 @@ on_error() {
56
56
exit " $1 "
57
57
}
58
58
59
- # Function to resolve GitHub handle to name and email using .mailmap
59
+ # Resolves GitHub handle to name and email using .mailmap.
60
60
#
61
61
# $1 - GitHub handle
62
62
resolve_user () {
@@ -76,7 +76,7 @@ resolve_user() {
76
76
fi
77
77
}
78
78
79
- # Function to make authenticated GitHub API requests
79
+ # Makes authenticated GitHub API requests.
80
80
#
81
81
# $1 - HTTP method (GET or POST)
82
82
# $2 - API endpoint
@@ -114,12 +114,21 @@ main() {
114
114
# Extract co-authors from commits:
115
115
co_authors=$( echo " $pr_commits " | jq -r ' .[].commit.message' | grep -i " Co-authored-by:" | awk -F' : ' ' {print $2}' | sort | uniq | paste -sd ' \n' -)
116
116
117
- # Extract linked issues from PR body (e.g., #123)
117
+ # Extract 'Signed-off-by' lines from commits:
118
+ signed_off_bys=$( echo " $pr_commits " | jq -r ' .[].commit.message' | grep -Eio ' Signed-off-by:.*' | sort -u)
119
+
120
+ # Extract linked issues from PR body (e.g., #123):
118
121
issue_numbers=$( echo " $pr_body " | grep -oE ' #[0-9]+' | grep -oE ' [0-9]+' | sort | uniq)
119
122
closes_issues=" "
120
123
ref_issues=" "
124
+
125
+ # GitHub-supported closing keywords:
126
+ closing_keywords=(" close" " closes" " closed" " fix" " fixes" " fixed" " resolve" " resolves" " resolved" )
127
+ # Create a regex pattern from the keywords:
128
+ keywords_pattern=$( IFS=' |' ; echo " ${closing_keywords[*]} " )
129
+
121
130
for issue in $issue_numbers ; do
122
- if echo " $pr_body " | grep -qi " closes. *#$issue " ; then
131
+ if echo " $pr_body " | grep -Eiq " ( ${keywords_pattern} )([[:space:]]+|:)[[:space:]] *#${ issue} \b " ; then
123
132
closes_issues+=" Closes: https://github.com/$REPO_OWNER /$REPO_NAME /issues/$issue \n"
124
133
else
125
134
ref_issues+=" Ref: https://github.com/$REPO_OWNER /$REPO_NAME /issues/$issue \n"
@@ -146,10 +155,10 @@ main() {
146
155
commit_body+=" \nReviewed-by: $resolved_reviewer "
147
156
done
148
157
149
- # Add Signed-off-by line :
150
- pr_author= $( echo " $pr_details " | jq -r ' .user.login ' )
151
- signed_off_by= $( resolve_user " $pr_author " )
152
- commit_body+= " \nSigned-off-by: $signed_off_by "
158
+ # Include Signed-off-by lines if present in the commits :
159
+ if [ -n " $signed_off_bys " ] ; then
160
+ commit_body+= " \n $signed_off_bys "
161
+ fi
153
162
154
163
# Combine subject and body:
155
164
commit_message=" $commit_subject \n\n$commit_body "
0 commit comments