diff --git a/.github/workflows/dco-post-merge.yml b/.github/workflows/dco-post-merge.yml index 9484d2a89f..844efd9b01 100644 --- a/.github/workflows/dco-post-merge.yml +++ b/.github/workflows/dco-post-merge.yml @@ -289,6 +289,25 @@ env: # from clubanderson in #14064: the maintainer merging the PR that adds # this entry IS that disposition. + # 687c3cb006d7559135f5f2fb0db13476d1af2a43 — the squash of #15315 (fix: stop + # filing the pre-restart kick-undeliverable warning as a fleet issue), on + # v5, reported by the monitor in #15401. mismatched-signoff of a NEW shape: + # same person: author uses GitHub noreply (id 91499691, @odttlnt), sign-off + # uses verified work email; pre-merge DCO passed (#15315). GitHub's squash + # wrote the PR author's private-email identity, Sachin Naik + # <91499691+odttlnt@users.noreply.github.com>, over a branch commit + # (97a705ca) authored AND signed off as SACHIN NAIK ; + # probot DCO and the squash-attribution gate both accepted it because the + # commits API resolves that address to @odttlnt. The checker now accepts + # this shape on its own (same-person-noreply, #15401) when v5 history + # carries local evidence of the link; for this first commit from the + # contributor there is none on v5 yet (the only prior commit under the work + # address is the PR branch commit itself), so it is waived. Protected v5 + # history cannot be re-signed in place. Accepted by maintainer disposition + # in #15401: the maintainer merging the PR that adds this entry IS that + # disposition. Expect STALE-WAIVER once the contributor's next commit lands + # under the work address; remove the entry then. + # KNOWN FAILING COMMITS THAT ARE DELIBERATELY *NOT* WAIVED # # Deep history carries further genuine mismatches — 8b536911 and, on v5 @@ -300,7 +319,7 @@ env: # regression. They are intentionally left unwaived: pre-approving them would # grow this list for commits that are not actually being reported, which is # the exact failure mode #6770 was filed about. - DCO_WAIVED_COMMITS: 'b798382a4d98ada28b0cb813644a595db0c58b08 7e01fee4a2c1a37f4a4072bf2d17e76e27113d01 d8f376e8e95f7b0c7d48d2b05b3a2a07ac9ee69b 4b9261183378a1a02a921cd0cc9df31e6f37993b 01bd2469e7a4022fff3fc04c42226c4d90c2f410 e29343efbb6e0721ca665ed8bd587d08997325e2 a8104b0cbeee1c4ac41034ac3f9951e6b5ac1200 692d068ffa198895ab91bd7ad663971f2b8ad358 b893b01c90e6ffff951523d20b19e9dfbfa80184 a0de3f920ded7e0cfc287bb5009d542e5a14f014 c6c78c3a26c33c6d1530996df20ead0a6b699dda a9200f3d278fcdbf6291f37f921845113814686e fb153585e6dab7b6f6808cb328e706d691f9be79 00070300002c88fda6850278edaea2498e8ca941 511027d8174be02b1dd77c25e9f8d5265f7fb7d4' + DCO_WAIVED_COMMITS: 'b798382a4d98ada28b0cb813644a595db0c58b08 7e01fee4a2c1a37f4a4072bf2d17e76e27113d01 d8f376e8e95f7b0c7d48d2b05b3a2a07ac9ee69b 4b9261183378a1a02a921cd0cc9df31e6f37993b 01bd2469e7a4022fff3fc04c42226c4d90c2f410 e29343efbb6e0721ca665ed8bd587d08997325e2 a8104b0cbeee1c4ac41034ac3f9951e6b5ac1200 692d068ffa198895ab91bd7ad663971f2b8ad358 b893b01c90e6ffff951523d20b19e9dfbfa80184 a0de3f920ded7e0cfc287bb5009d542e5a14f014 c6c78c3a26c33c6d1530996df20ead0a6b699dda a9200f3d278fcdbf6291f37f921845113814686e fb153585e6dab7b6f6808cb328e706d691f9be79 00070300002c88fda6850278edaea2498e8ca941 511027d8174be02b1dd77c25e9f8d5265f7fb7d4 687c3cb006d7559135f5f2fb0db13476d1af2a43' # Tide/tagged-release failures discussed in #6276 came from human squash # commits and release metadata, not bot-authored commits. Skip bots here so # release automation is not paged for bracketed bot-address edge cases that diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5f3c241b1..fda1207856 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -258,6 +258,21 @@ rewritten; their failures are resolved by maintainer disposition, not by you. blast radius — are documented in [`src/docs/v5-sync-policy.md`](src/docs/v5-sync-policy.md#inherited-dco-failures-from-v4). + One identity shape the post-merge check resolves on its own: GitHub's squash + writes the pull-request author's GitHub identity on the landing commit, so a + contributor with a private email lands as + `+@users.noreply.github.com` while the `Signed-off-by:` carried + over from the branch is their real address — the one the pre-merge DCO check + already accepted. The checker treats that as the same person **only when the + protected branch's own history shows the link**: another commit authored or + committed under the sign-off address by the same name, or a commit on which + that address and ``'s noreply appear together. It makes no GitHub API + call for this, and it reports each acceptance as an informational + `same-person-noreply … evidence=:` line rather than hiding it. A + first-time contributor's squash has no such evidence yet and still needs a + per-SHA waiver, which becomes `STALE-WAIVER` once their next commit under + that address lands ([#15401](https://github.com/hivecommons/hive/issues/15401)). + All four reuse the same trailer validation (`src/scripts/check-dco-trailers.sh` for the range-scanning gates), and the sign-off *identity* rules — noreply matching and author-login lookup — live in one shared library, diff --git a/changelog.d/fixed-dco-postmerge-noreply-identity.md b/changelog.d/fixed-dco-postmerge-noreply-identity.md new file mode 100644 index 0000000000..8d40a2aa36 --- /dev/null +++ b/changelog.d/fixed-dco-postmerge-noreply-identity.md @@ -0,0 +1 @@ +- The post-merge DCO trailer check (`src/scripts/check-dco-trailers.sh`) no longer fails a squash commit whose author is a GitHub noreply address (`+@users.noreply.github.com`) signed off under the same contributor's real email, when the branch's own history shows the two identities belong to one person; such commits are reported as informational `same-person-noreply` lines naming the evidence commit, with no GitHub API call. The v5 squash of #15315 (`687c3cb0`) is waived until that evidence exists on v5 ([#15401](https://github.com/hivecommons/hive/issues/15401)). diff --git a/src/docs/v5-sync-policy.md b/src/docs/v5-sync-policy.md index 9aa0fefa7b..0515e9dc4e 100644 --- a/src/docs/v5-sync-policy.md +++ b/src/docs/v5-sync-policy.md @@ -219,6 +219,20 @@ only one that can clear a commit that carries no trailer at all. Reach for the email allowlist only when the intent really is to accept an identity's alternate address going forward. +Before reaching for either, check whether the checker can resolve the commit +itself. A squash whose author is a GitHub noreply address +(`+@users.noreply.github.com`) and whose sign-off is the same +contributor's real address is accepted as `same-person-noreply` when the +branch's history (last `DCO_SAME_PERSON_WINDOW` commits, default 500) carries +local evidence of the link — the same name authored under the sign-off +address before, or both identities appear on one earlier commit. Each +acceptance is printed with the evidence commit; no GitHub API call is made. +`DCO_SAME_PERSON_EVIDENCE_REFS` adds refs (for example a fetched +`refs/pull/N/head`) to that search for a local check. Only a contributor's +first such squash, which has no prior history, needs a waiver — and that +waiver is reported `STALE-WAIVER` once their next commit under that address +lands ([#15401](https://github.com/hivecommons/hive/issues/15401)). + Neither instrument is silent. A waived commit is reported on every run as `WAIVED …` above the failures, the summary line counts waivers, and a green run carrying them says `passed (with recorded waivers)` rather than diff --git a/src/scripts/check-dco-trailers.sh b/src/scripts/check-dco-trailers.sh index cd20801fb2..c13b3ada08 100755 --- a/src/scripts/check-dco-trailers.sh +++ b/src/scripts/check-dco-trailers.sh @@ -1,7 +1,11 @@ #!/usr/bin/env bash # Check recent protected-branch commits for a DCO trailer whose email matches # the commit author. GitHub noreply addresses are accepted only when the -# GitHub commits API identifies the commit author as that exact login. +# GitHub commits API identifies the commit author as that exact login. A +# noreply AUTHOR (the shape GitHub's squash writes for a private-email PR +# author) signed off under another address is accepted only when the branch's +# own history supplies local evidence that the two identities are one person; +# see same_person_noreply_evidence below (#15401). # Maintainer override identities can be supplied with DCO_ALLOWLIST_EMAILS, but # the default is intentionally empty so normal runs require the squash author's # own sign-off. @@ -44,6 +48,8 @@ ref="${2:-${DCO_REF:-HEAD}}" allowlist_raw="${DCO_ALLOWLIST_EMAILS:-}" waived_raw="${DCO_WAIVED_COMMITS:-}" skip_bots="${DCO_SKIP_BOT_AUTHORS:-true}" +same_person_window="${DCO_SAME_PERSON_WINDOW:-500}" +same_person_extra_refs="${DCO_SAME_PERSON_EVIDENCE_REFS:-}" usage() { cat >&2 <<'USAGE' @@ -67,6 +73,13 @@ Environment: DCO_AUTHOR_LOGIN_MAP Optional comma/space/newline-separated SHA=login map used before the GitHub API, mainly for tests/offline runs. Empty by default. + DCO_SAME_PERSON_WINDOW Number of commits of history searched for LOCAL evidence + that a GitHub-noreply author and a differently-addressed + sign-off are the same person (default: 500; 0 disables). + DCO_SAME_PERSON_EVIDENCE_REFS + Optional extra refs (space-separated) whose history is + searched for that evidence in addition to the inspected + ref, e.g. a fetched refs/pull/N/head. Empty by default. USAGE } @@ -78,6 +91,9 @@ if [ "$limit" -eq 0 ]; then usage exit 2 fi +case "$same_person_window" in + ''|*[!0-9]*) echo "DCO_SAME_PERSON_WINDOW must be a non-negative integer: $same_person_window" >&2; exit 2 ;; +esac # `ref` may be a single commit-ish (the rolling-window form used by the hourly # monitor) or a two-dot RANGE like ... The range form exists for @@ -114,6 +130,23 @@ case "$ref" in ;; esac +# The history searched for same-person evidence is the inspected branch +# itself (the tip of a range, or the ref), plus any refs the operator fetched +# on purpose. In CI only the protected branch is checked out, so the default +# is exactly the branch's own history and nothing a PR could smuggle in. +case "$ref" in + *..*) evidence_tip="${ref##*..}" ;; + *) evidence_tip="$ref" ;; +esac +evidence_refs="$evidence_tip" +for extra_ref in $same_person_extra_refs; do + if ! git rev-parse --verify --quiet "${extra_ref}^{commit}" >/dev/null; then + echo "DCO_SAME_PERSON_EVIDENCE_REFS entry does not resolve to a commit: $extra_ref" >&2 + exit 2 + fi + evidence_refs="$evidence_refs $extra_ref" +done + email_allowed() { needle=$(printf '%s' "$1" | lower) [ -n "$needle" ] || return 1 @@ -193,7 +226,84 @@ extract_signoff_emails() { }' } +# same_person_noreply_evidence +# +# GitHub's squash merge writes the PR author's GitHub identity on the landing +# commit. For an account with a private email that is +# `+@users.noreply.github.com`, while the Signed-off-by carried over +# from the branch is the contributor's real address — the one the pre-merge DCO +# app already accepted on the branch commits (#15401, 687c3cb0). The two +# addresses belong to one person, but the trailer alone cannot show it. +# +# This looks for LOCAL evidence of the link, with no GitHub API call, in the +# last DCO_SAME_PERSON_WINDOW commits reachable from the inspected branch (and +# any DCO_SAME_PERSON_EVIDENCE_REFS). Accepts when another commit: +# +# authored-under-signoff-email was authored or committed under the sign-off +# address by the same name (case-insensitive) as +# this commit's author — the person has written +# to this repository under that address before; +# login-and-email-cooccur has the sign-off address as author/committer +# AND names 's noreply address in its own +# identities or Signed-off-by lines — the two +# identities are tied together on a commit that +# passed in the opposite orientation. +# +# A commit of the SAME shape as the one under test (noreply author, foreign +# sign-off) is deliberately not evidence: repetition of the ambiguity is not a +# resolution of it. Prints the evidence as `:` on success. +same_person_noreply_evidence() { + sp_sha="$1" + sp_author_name_lc=$(printf '%s' "$2" | lower) + sp_author_lc="$3" + sp_signoff_lc="$4" + + [ "$same_person_window" -gt 0 ] || return 1 + sp_login=$(github_noreply_login "$sp_author_lc") || return 1 + # A noreply sign-off is the login-lookup path's business, not this one's. + case "$sp_signoff_lc" in + *@users.noreply.github.com) return 1 ;; + esac + [ -n "$sp_author_name_lc" ] || return 1 + + # shellcheck disable=SC2086 # evidence_refs is a deliberate word list + while IFS=$'\x1f' read -r ev_sha ev_an ev_ae ev_cn ev_ce; do + [ -n "$ev_sha" ] || continue + [ "$ev_sha" != "$sp_sha" ] || continue + ev_ae_lc=$(printf '%s' "$ev_ae" | lower) + ev_ce_lc=$(printf '%s' "$ev_ce" | lower) + ev_an_lc=$(printf '%s' "$ev_an" | lower) + ev_cn_lc=$(printf '%s' "$ev_cn" | lower) + + if { [ "$ev_ae_lc" = "$sp_signoff_lc" ] && [ "$ev_an_lc" = "$sp_author_name_lc" ]; } || + { [ "$ev_ce_lc" = "$sp_signoff_lc" ] && [ "$ev_cn_lc" = "$sp_author_name_lc" ]; }; then + printf 'authored-under-signoff-email:%s' "$(git rev-parse --short "$ev_sha")" + return 0 + fi + + if [ "$ev_ae_lc" = "$sp_signoff_lc" ] || [ "$ev_ce_lc" = "$sp_signoff_lc" ]; then + if github_noreply_matches_login "$ev_ae_lc" "$sp_login" || + github_noreply_matches_login "$ev_ce_lc" "$sp_login"; then + printf 'login-and-email-cooccur:%s' "$(git rev-parse --short "$ev_sha")" + return 0 + fi + while IFS= read -r ev_signoff; do + [ -n "$ev_signoff" ] || continue + if github_noreply_matches_login "$ev_signoff" "$sp_login"; then + printf 'login-and-email-cooccur:%s' "$(git rev-parse --short "$ev_sha")" + return 0 + fi + done < signed-off-by=${rendered}" @@ -285,8 +409,8 @@ case "$ref" in *..*) scanned_scope='commits in' ;; *) scanned_scope='recent commits on' ;; esac -printf 'DCO trailer check inspected %s %s %s (%s non-merge, non-bot checked; %s merge skipped; %s bot skipped; %s waived).\n' \ - "$limit" "$scanned_scope" "$ref" "$checked" "$skipped_merges" "$skipped_bots" "$waived_count" +printf 'DCO trailer check inspected %s %s %s (%s non-merge, non-bot checked; %s merge skipped; %s bot skipped; %s waived; %s same-person-noreply).\n' \ + "$limit" "$scanned_scope" "$ref" "$checked" "$skipped_merges" "$skipped_bots" "$waived_count" "$same_person_count" # Waived commits print on every run, above the failures. A disposition that # produced no output would be an invisible hole in a compliance check; keeping @@ -296,6 +420,13 @@ if [ -n "$waived_report" ]; then printf '%b' "$waived_report" fi +# Same-person acceptances are informational, never hidden: each one names the +# commit in the branch history that supplied the evidence, so a reader can +# audit the inference rather than take it on trust. +if [ -n "$same_person_report" ]; then + printf '%b' "$same_person_report" +fi + # Stale waivers are advisory, not fatal: failing the monitor over config # housekeeping would page the same people this change is trying to stop paging. if [ -n "${stale_waivers:-}" ]; then diff --git a/src/scripts/lib-dco-identity.sh b/src/scripts/lib-dco-identity.sh index 273beec508..d5f98e5594 100644 --- a/src/scripts/lib-dco-identity.sh +++ b/src/scripts/lib-dco-identity.sh @@ -105,6 +105,34 @@ author_login_for_commit() { github_api_author_login "$sha_arg" || true } +# Print the GitHub login encoded in a noreply address: both the plain +# `login@users.noreply.github.com` and the numeric +# `+login@users.noreply.github.com` forms. Prints nothing and returns 1 for +# any other address. The login is a STRUCTURAL fact of the address (GitHub +# mints these itself), which is what lets a checker reason about it offline. +github_noreply_login() { + email_lc=$(printf '%s' "$1" | lower) + suffix='@users.noreply.github.com' + case "$email_lc" in + *"$suffix") ;; + *) return 1 ;; + esac + local_part=${email_lc%"$suffix"} + [ -n "$local_part" ] || return 1 + case "$local_part" in + *+*) + id_part=${local_part%%+*} + login_part=${local_part#*+} + case "$id_part" in + ''|*[!0-9]*) return 1 ;; + esac + [ -n "$login_part" ] || return 1 + printf '%s' "$login_part" + ;; + *) printf '%s' "$local_part" ;; + esac +} + # Is $1 (a lower-cased email) the GitHub noreply address for login $2? # Accepts both `login@users.noreply.github.com` and the numeric # `+login@users.noreply.github.com` form. diff --git a/src/scripts/test-check-dco-trailers.sh b/src/scripts/test-check-dco-trailers.sh index 9167b5a289..49dd93e029 100755 --- a/src/scripts/test-check-dco-trailers.sh +++ b/src/scripts/test-check-dco-trailers.sh @@ -335,6 +335,201 @@ else echo "$output" | sed 's/^/ | /' fi +# --- same-person noreply author (hivecommons/hive#15401) --------------------- +# +# GitHub's squash writes the PR author's GitHub identity on the landing commit. +# For a private-email account that is `+@users.noreply.github.com`, +# while the Signed-off-by carried over from the branch is the contributor's real +# address (v5 687c3cb0: author 91499691+odttlnt@…, sign-off +# sachin.naik@ibm.com). Same person; the checker must accept it only when the +# branch's own history shows the link, and must say which commit showed it. +sp_repo="$TMP/same-person" +mkdir -p "$sp_repo" +cd "$sp_repo" || exit 1 +git init -q + +# Evidence commit A: the contributor authored under the real address before, +# under the same name (case differs, as it does on v5 97a705ca vs 687c3cb0). +git config user.name 'SACHIN NAIK' +git config user.email 'sachin.naik@example.com' +echo one > f.txt +git add f.txt +git commit -q -m $'earlier commit under work address\n\nSigned-off-by: SACHIN NAIK ' +sp_evidence_a_sha=$(git rev-parse HEAD) + +# The squash shape under test: noreply author, work-address sign-off. +git config user.name 'Sachin Naik' +git config user.email '91499691+odttlnt@users.noreply.github.com' +echo two >> f.txt +git add f.txt +git commit -q -m $'squash of a private-email PR\n\nSigned-off-by: SACHIN NAIK ' +sp_squash_sha=$(git rev-parse HEAD) + +# Negative: a noreply author whose foreign sign-off has NO history anywhere. +git config user.name 'Nobody Known' +git config user.email '555+nobody-known@users.noreply.github.com' +echo three >> f.txt +git add f.txt +git commit -q -m $'noreply author, unknown sign-off\n\nSigned-off-by: Nobody Known ' +sp_unknown_sha=$(git rev-parse HEAD) + +# Negative: the sign-off address HAS history, but under a different name. A +# shared address alone is not a same-person link. +git config user.name 'Imposter Noreply' +git config user.email '777+imposter@users.noreply.github.com' +echo four >> f.txt +git add f.txt +git commit -q -m $'noreply author, someone else\'s address\n\nSigned-off-by: SACHIN NAIK ' +sp_imposter_sha=$(git rev-parse HEAD) + +# Negative: the only "evidence" is another commit of the SAME ambiguous shape +# (noreply author + the same foreign sign-off). Repetition is not resolution. +git config user.name 'Repeat Offender' +git config user.email '888+repeat-offender@users.noreply.github.com' +echo five >> f.txt +git add f.txt +git commit -q -m $'first of two identical mismatches\n\nSigned-off-by: Repeat Offender ' +sp_repeat_a_sha=$(git rev-parse HEAD) +echo six >> f.txt +git add f.txt +git commit -q -m $'second of two identical mismatches\n\nSigned-off-by: Repeat Offender ' +sp_repeat_b_sha=$(git rev-parse HEAD) + +# Evidence commit B (co-occurrence): authored under the real address and +# signed off as the login's own noreply — the two identities tied together in +# the orientation the login-lookup path already accepts. The author NAME +# differs from the squash's, so the name-based rule cannot be what accepts it. +git config user.name 'P. Cooccur (work)' +git config user.email 'pat@example.com' +echo seven >> f.txt +git add f.txt +git commit -q -m $'authored as work address, signed as own noreply\n\nSigned-off-by: Pat Cooccur <424242+patco@users.noreply.github.com>' +sp_evidence_b_sha=$(git rev-parse HEAD) +git config user.name 'Pat Cooccur' +git config user.email '424242+patco@users.noreply.github.com' +echo eight >> f.txt +git add f.txt +git commit -q -m $'squash for patco\n\nSigned-off-by: Pat Cooccur ' +sp_cooccur_sha=$(git rev-parse HEAD) + +run_sp() { # run_sp + set +e + output=$(env "DCO_AUTHOR_LOGIN_MAP=${sp_evidence_b_sha}=patco" "$@" bash "$CHECKER" 20 HEAD 2>&1) + rc=$? + set -e +} + +run_sp "DCO_WAIVED_COMMITS=" +if out_grep -q "^same-person-noreply ${sp_squash_sha} .*evidence=authored-under-signoff-email:$(git rev-parse --short "$sp_evidence_a_sha")"; then + pass "a noreply author is accepted when the same name authored under the sign-off address before, citing that commit" +else + bad "same-person noreply squash ${sp_squash_sha} was not accepted with authored-under-signoff-email evidence" + echo "$output" | sed 's/^/ | /' +fi +if out_grep -q "^FAIL ${sp_squash_sha}"; then + bad "same-person noreply squash ${sp_squash_sha} still reported as FAIL" +fi +if out_grep -q "^same-person-noreply ${sp_cooccur_sha} .*evidence=login-and-email-cooccur:$(git rev-parse --short "$sp_evidence_b_sha")"; then + pass "a noreply author is accepted when the sign-off address and the login's noreply co-occur on another commit" +else + bad "co-occurrence squash ${sp_cooccur_sha} was not accepted with login-and-email-cooccur evidence" + echo "$output" | sed 's/^/ | /' +fi +if out_grep -q "^FAIL ${sp_unknown_sha} mismatched-signoff"; then + pass "a noreply author with an unknown sign-off address still fails" +else + bad "unknown-address noreply commit ${sp_unknown_sha} was not reported" + echo "$output" | sed 's/^/ | /' +fi +if out_grep -q "^FAIL ${sp_imposter_sha} mismatched-signoff"; then + pass "a noreply author signing off as a different-named known address still fails" +else + bad "imposter noreply commit ${sp_imposter_sha} was not reported" + echo "$output" | sed 's/^/ | /' +fi +if out_grep -q "^FAIL ${sp_repeat_a_sha} mismatched-signoff" && out_grep -q "^FAIL ${sp_repeat_b_sha} mismatched-signoff"; then + pass "two commits of the same ambiguous shape are not evidence for each other" +else + bad "repeated noreply/foreign-signoff pair was accepted without evidence" + echo "$output" | sed 's/^/ | /' +fi +if out_grep -q '2 same-person-noreply)'; then + pass "the summary line counts same-person acceptances" +else + bad "summary did not report 2 same-person-noreply" + echo "$output" | sed 's/^/ | /' +fi + +# The heuristic is a strict addition: with the window disabled the squash is +# an ordinary mismatched-signoff again, and a waiver covers it exactly as before. +run_sp "DCO_WAIVED_COMMITS=" "DCO_SAME_PERSON_WINDOW=0" +if out_grep -q "^FAIL ${sp_squash_sha} mismatched-signoff" && ! out_grep -q '^same-person-noreply '; then + pass "DCO_SAME_PERSON_WINDOW=0 disables the heuristic" +else + bad "window=0 did not disable the same-person heuristic (rc=${rc})" + echo "$output" | sed 's/^/ | /' +fi +run_sp "DCO_WAIVED_COMMITS=${sp_squash_sha}" "DCO_SAME_PERSON_WINDOW=0" +if out_grep -q "^WAIVED ${sp_squash_sha} mismatched-signoff"; then + pass "a waiver still covers the squash when no evidence is available" +else + bad "waiver on ${sp_squash_sha} was not honoured with the heuristic disabled" + echo "$output" | sed 's/^/ | /' +fi + +# A waiver on a commit the heuristic now accepts is dead weight, and is +# reported as such so it gets removed — the same convergence rule as #6770. +run_sp "DCO_WAIVED_COMMITS=${sp_squash_sha}" +if out_grep -q "^STALE-WAIVER ${sp_squash_sha}"; then + pass "a waiver on a same-person-accepted commit is reported as stale" +else + bad "stale waiver on ${sp_squash_sha} was not reported" + echo "$output" | sed 's/^/ | /' +fi + +# Evidence may come from an extra ref the operator fetched on purpose (e.g. the +# PR's own branch), and only from refs that resolve. +git checkout -q -b evidence-only "$sp_evidence_a_sha" +git checkout -q -b scan-tip "$sp_squash_sha" +git branch -q -D master 2>/dev/null || git branch -q -D main 2>/dev/null || true +set +e +output=$(DCO_SAME_PERSON_WINDOW=0 bash "$CHECKER" 1 scan-tip 2>&1); rc=$? +set -e +if out_grep -q "^FAIL ${sp_squash_sha} mismatched-signoff"; then + pass "with no evidence ref the squash alone is a mismatch" +else + bad "squash-only scan did not fail as expected (rc=${rc})" + echo "$output" | sed 's/^/ | /' +fi +set +e +output=$(DCO_SAME_PERSON_EVIDENCE_REFS=evidence-only bash "$CHECKER" 1 "${sp_evidence_a_sha}..${sp_squash_sha}" 2>&1); rc=$? +set -e +if [ "$rc" -eq 0 ] && out_grep -q "^same-person-noreply ${sp_squash_sha} .*evidence=authored-under-signoff-email:"; then + pass "DCO_SAME_PERSON_EVIDENCE_REFS supplies evidence from outside the scanned range" +else + bad "evidence ref was not consulted (rc=${rc})" + echo "$output" | sed 's/^/ | /' +fi +set +e +output=$(DCO_SAME_PERSON_EVIDENCE_REFS=no-such-ref bash "$CHECKER" 1 scan-tip 2>&1); rc=$? +set -e +if [ "$rc" -eq 2 ]; then + pass "an unresolvable evidence ref is a config error" +else + bad "bad evidence ref should exit 2, got ${rc}" + echo "$output" | sed 's/^/ | /' +fi +set +e +output=$(DCO_SAME_PERSON_WINDOW=lots bash "$CHECKER" 1 scan-tip 2>&1); rc=$? +set -e +if [ "$rc" -eq 2 ]; then + pass "a non-numeric DCO_SAME_PERSON_WINDOW is a config error" +else + bad "non-numeric window should exit 2, got ${rc}" + echo "$output" | sed 's/^/ | /' +fi +cd "$repo" || exit 1 + if [ "$fail" -ne 0 ]; then echo "test-check-dco-trailers FAILED" exit 1