Skip to content

Commit 9e0bdb6

Browse files
committed
MINOR: warn about Assisted-by and Signed-off-by commit trailers
Update the check-committer GitLab CI job to scan for Assisted-by and Signed-off-by trailers in commit messages. If these trailers are detected, the pipeline will now fail and report the violations in the JUnit test report.
1 parent 7dccbcb commit 9e0bdb6

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

.gitlab/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ check-committer:
125125
esac
126126
done
127127
CO_AUTHORED=""
128+
ASSISTED=""
129+
SIGNED_OFF=""
128130
for COMMIT in $(git log --format='%H' origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}..HEAD); do
129131
BODY=$(git log -1 --format='%b' "$COMMIT")
130132
MSG=$(git log -1 --format='%s' "$COMMIT")
@@ -134,6 +136,18 @@ check-committer:
134136
CO_AUTHORED="${CO_AUTHORED}${SHORT} ${MSG}\n$(echo "$MATCHED" | sed 's/^/ /')\n"
135137
junit-report add --status=failed --file="co-authored-by" --message="$MSG" --description="$(printf "commit contains Co-authored-by trailer\n\n%s\n%s" "$MSG" "$MATCHED")"
136138
fi
139+
MATCHED=$(echo "$BODY" | grep -i 'Assisted-by' || true)
140+
if [ -n "$MATCHED" ]; then
141+
SHORT=$(echo "$COMMIT" | cut -c1-8)
142+
ASSISTED="${ASSISTED}${SHORT} ${MSG}\n$(echo "$MATCHED" | sed 's/^/ /')\n"
143+
junit-report add --status=failed --file="assisted-by" --message="$MSG" --description="$(printf "commit contains Assisted-by trailer\n\n%s\n%s" "$MSG" "$MATCHED")"
144+
fi
145+
MATCHED=$(echo "$BODY" | grep -i 'Signed-off-by' || true)
146+
if [ -n "$MATCHED" ]; then
147+
SHORT=$(echo "$COMMIT" | cut -c1-8)
148+
SIGNED_OFF="${SIGNED_OFF}${SHORT} ${MSG}\n$(echo "$MATCHED" | sed 's/^/ /')\n"
149+
junit-report add --status=failed --file="signed-off-by" --message="$MSG" --description="$(printf "commit contains Signed-off-by trailer\n\n%s\n%s" "$MSG" "$MATCHED")"
150+
fi
137151
done
138152
FAILED=""
139153
if [ -n "$BAD_EMAILS" ]; then
@@ -152,6 +166,22 @@ check-committer:
152166
echo "No commits contain Co-authored-by."
153167
junit-report add --status=ok --file=co-authored-by --description="no co-authored-by found" --message="No commits contain Co-authored-by."
154168
fi
169+
if [ -n "$ASSISTED" ]; then
170+
echo "The following commits contain Assisted-by:"
171+
printf "$ASSISTED"
172+
FAILED=1
173+
else
174+
echo "No commits contain Assisted-by."
175+
junit-report add --status=ok --file=assisted-by --description="no assisted-by found" --message="No commits contain Assisted-by."
176+
fi
177+
if [ -n "$SIGNED_OFF" ]; then
178+
echo "The following commits contain Signed-off-by:"
179+
printf "$SIGNED_OFF"
180+
FAILED=1
181+
else
182+
echo "No commits contain Signed-off-by."
183+
junit-report add --status=ok --file=signed-off-by --description="no signed-off-by found" --message="No commits contain Signed-off-by."
184+
fi
155185
if [ -n "$FAILED" ]; then
156186
exit 1
157187
fi

0 commit comments

Comments
 (0)