@@ -130,6 +130,16 @@ get_all_match_positions() {
130
130
done <<< " $targets"
131
131
}
132
132
133
+ KNOWN_TRAILERS_BY= (
134
+ ' Signed-off-by'
135
+ ' Reviewed-by'
136
+ ' Co-authored-by'
137
+ ' Acked-by'
138
+ ' Suggested-by'
139
+ ' Tested-by'
140
+ ' Reported-by'
141
+ )
142
+
133
143
# Build regex for detecting commit trailers.
134
144
build_commit_trailer_regex () {
135
145
local -a keys specials standalones trailers
@@ -145,12 +155,17 @@ build_commit_trailer_regex() {
145
155
' Signed-off-by' ' Suggested-by' ' Tested-by'
146
156
)
147
157
158
+ trailers_test=(
159
+ ' CC' ' Change-Id' ' Closes'
160
+ " ${KNOWN_TRAILERS_BY[@]} "
161
+ )
148
162
# Standalone keys (those that do not require a value).
149
163
standalones=(
150
164
' (Doc|Upgrade|Security)Impact'
151
165
" Git-Dch[$separators ] (Ignore|Short|Full)"
152
166
)
153
167
168
+
154
169
# Read custom trailer keys from git config and add them either to specials or trailers.
155
170
# This loop reads lines matching 'trailer.*.key'.
156
171
while read -r _ key; do
@@ -170,6 +185,10 @@ build_commit_trailer_regex() {
170
185
fi
171
186
done < <( git config --get-regexp ' trailer.*.key' )
172
187
188
+ if [[ ${# trailers_by[@]} -eq 0 ]]; then
189
+ trailers_by=(" ${DEFAULT_TRAILERS_BY[@]} " )
190
+ fi
191
+
173
192
# Possible trailers :
174
193
# - Acked-by
175
194
# - Co-authored-by
@@ -178,8 +197,7 @@ build_commit_trailer_regex() {
178
197
# - Signed-off-by
179
198
# - Suggested-by
180
199
# - Tested-by
181
- TRAILERS_BY_REGEX=" ^($( IFS=' |' ; echo " ${trailers_by[*]} " ) ):"
182
-
200
+ TRAILERS_BY_REGEX=" /($( IFS=' |' ; echo " ${trailers_by[*]} " | tr ' [:upper:]' ' [:lower:]' ) )/"
183
201
# Begin constructing the regex.
184
202
TRAILER_REGEX=' ^('
185
203
@@ -610,7 +628,7 @@ add_change_id() {
610
628
other_footer = ""
611
629
612
630
for (line = 1; line <= numlines; line++) {
613
- if (match(tolower(footer[line]), TRAILERS_BY_REGEX)) {
631
+ if (match(tolower(footer[line]), ' " $ TRAILERS_BY_REGEX" ' )) {
614
632
trailers = trailers footer[line] "\n"
615
633
} else {
616
634
other_footer = other_footer footer[line] "\n"
0 commit comments