@@ -154,29 +154,31 @@ build_commit_trailer_regex() {
154
154
# Read custom trailer keys from git config and add them either to specials or trailers.
155
155
# This loop reads lines matching 'trailer.*.key'.
156
156
while read -r _ key; do
157
- # Skip if key already exists in trailers or specials.
157
+ if [[ " $key " =~ -b y$ ]]; then
158
+ trailers_by+=(" $key " )
159
+ continue
160
+ fi
161
+
158
162
for each in " ${trailers[@]} " " ${specials[@]} " ; do
159
- if [ " $key " = " $each " ]; then
160
- continue 2
161
- fi
163
+ [[ " $key " == " $each " ]] && continue 2
162
164
done
163
- # If key ends with a separator character, add to specials; otherwise, to trailers.
165
+
164
166
if [[ $key =~ [${separators} ]$ ]]; then
165
167
specials+=(" $key " )
166
168
else
167
169
trailers+=(" $key " )
168
170
fi
169
171
done < <( git config --get-regexp ' trailer.*.key' )
170
172
171
- # Read custom trailer keys again into the 'keys' array (if needed).
172
- while IFS=. read -r _ key _ ; do
173
- for each in " ${keys[@]} " ; do
174
- if [ " $key " = " $each " ] ; then
175
- continue 2
176
- fi
177
- done
178
- keys+=( " $key " )
179
- done < <( git config --get-regexp ' trailer.*.key ' )
173
+ # Possible trailers :
174
+ # - Acked-by
175
+ # - Co-authored-by
176
+ # - Reported-by
177
+ # - Reviewed-by
178
+ # - Signed-off-by
179
+ # - Suggested-by
180
+ # - Tested-by
181
+ TRAILERS_BY_REGEX= " ^( $( IFS= ' | ' ; echo " ${trailers_by[*]} " ) ): "
180
182
181
183
# Begin constructing the regex.
182
184
TRAILER_REGEX=' ^('
@@ -209,16 +211,6 @@ build_commit_trailer_regex() {
209
211
TRAILER_REGEX=" ${TRAILER_REGEX% |} )"
210
212
fi
211
213
212
- # Append additional keys.
213
- if (( ${# keys[@]} > 0 )) ; then
214
- TRAILER_REGEX+=' |(('
215
- for each in " ${keys[@]} " ; do
216
- TRAILER_REGEX+=" $each |"
217
- done
218
- # Use the second character of separators (if available) as a separator for keys.
219
- TRAILER_REGEX=" ${TRAILER_REGEX% |} )[${separators: 1: 1} [:blank:]])"
220
- fi
221
-
222
214
# End the regex.
223
215
TRAILER_REGEX+=" )"
224
216
}
@@ -618,7 +610,7 @@ add_change_id() {
618
610
other_footer = ""
619
611
620
612
for (line = 1; line <= numlines; line++) {
621
- if (match(tolower(footer[line]), /^(signed-off-by|acked-by|co-authored-by|reviewed-by|tested-by|suggested-by|reported-by):/ )) {
613
+ if (match(tolower(footer[line]), TRAILERS_BY_REGEX )) {
622
614
trailers = trailers footer[line] "\n"
623
615
} else {
624
616
other_footer = other_footer footer[line] "\n"
0 commit comments