You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo "##vso[task.logissue type=error]This PR has $commit_count commits. release/msrc/* PRs must contain exactly one commit. Please squash your commits."
288
-
exit 1
289
-
fi
290
-
echo "PR has a single commit."
284
+
# Check each commit in the PR for the Msrc-Case-Id trailer
285
+
commits=$(git rev-list "$base_sha..$head_sha")
286
+
commits_with_trailer=0
287
+
total_commits=0
291
288
292
-
# Extract every Msrc-Case-Id trailer value from the PR head commit.
echo "##vso[task.logissue type=error]Commit $head_sha is missing the required 'Msrc-Case-Id' trailer."
300
-
printf "Add a trailer to the commit message, for example:\n\n Msrc-Case-Id: 12345\n\nIf there is no associated case ID, use N/A:\n\n Msrc-Case-Id: N/A\n\n"
301
-
exit 1
302
-
fi
292
+
# Extract Msrc-Case-Id trailer values from this commit
# Every supplied case ID must be numeric or explicitly marked not applicable.
305
-
for value in "${trailer_values[@]}"; do
306
-
if [[ ! "$value" =~ ^[0-9]+$ && "$value" != "N/A" ]]; then
307
-
echo "##vso[task.logissue type=error]Commit $head_sha has an invalid 'Msrc-Case-Id' trailer value. Expected a number or N/A."
308
-
printf "Use a numeric case id or N/A, for example:\n\n Msrc-Case-Id: 12345\n\n"
309
-
exit 1
301
+
# Validate all trailer values are numeric or N/A
302
+
for value in "${trailer_values[@]}"; do
303
+
if [[ ! "$value" =~ ^[0-9]+$ && "$value" != "N/A" ]]; then
304
+
echo "##vso[task.logissue type=error]Commit $commit has an invalid 'Msrc-Case-Id' trailer value. Expected a number or N/A."
305
+
printf "Use a numeric case id or N/A, for example:\n\n Msrc-Case-Id: 12345\n\n"
306
+
exit 1
307
+
fi
308
+
done
309
+
310
+
echo "Commit $commit has the following 'Msrc-Case-Id' trailers: ${trailer_values[*]}"
310
311
fi
311
312
done
312
313
313
-
echo "Commit $head_sha has the required 'Msrc-Case-Id' trailer."
314
+
# At least one commit must have the Msrc-Case-Id trailer
315
+
if [ "$commits_with_trailer" -lt 1 ]; then
316
+
echo "##vso[task.logissue type=error]Expected at least one commit with 'Msrc-Case-Id' trailer, but found $commits_with_trailer out of $total_commits commits with a trailer."
317
+
printf "Add a trailer to at least one commit message, for example:\n\n Msrc-Case-Id: 12345\n\nIf there is no associated case ID, use N/A:\n\n Msrc-Case-Id: N/A\n\n"
0 commit comments