Accept a CLA signature line anywhere in a comment (#894)

This commit is contained in:
Glenn Jocher
2026-08-28 11:22:12 +02:00
committed by GitHub
parent 722ecbabb3
commit 83e6d67897
5 changed files with 22 additions and 9 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ permissions:
jobs:
CLA:
if: github.event_name == 'pull_request_target' || (github.event.issue.pull_request && (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I sign the CLA'))
if: github.event_name == 'pull_request_target' || (github.event.issue.pull_request && (contains(github.event.comment.body, 'recheck') || contains(github.event.comment.body, 'I have read the CLA Document and I sign the CLA')))
concurrency:
group: cla-${{ github.event.pull_request.number || github.event.issue.number }}
runs-on: ubuntu-latest
+1 -1
View File
@@ -28,4 +28,4 @@
# ├── test_summarize_pr.py
# └── ...
__version__ = "0.3.18"
__version__ = "0.3.19"
+4 -1
View File
@@ -22,6 +22,8 @@ CLA_PATH = "signatures/version1/cla.json"
CLA_BRANCH = "cla-signatures"
CLA_DOCUMENT = "https://docs.ultralytics.com/help/CLA"
SIGN_COMMENT = "I have read the CLA Document and I sign the CLA"
SIGN_TEXT = SIGN_COMMENT.casefold()
SIGN_STRIP = " \t*_`\"'.!,;:" # whitespace, markdown emphasis, quotes and end punctuation around a signature line
COMMENT_MARKER = "<!-- ultralytics-cla -->"
LEGACY_MARKER = "CLA Assistant Lite bot"
BOT_LOGIN = "github-actions[bot]"
@@ -224,7 +226,8 @@ def run(action: Action, ledger_action: Action) -> None:
records = {
comment["user"]["id"]: _record(comment, action, number)
for comment in comments
if comment.get("body") == SIGN_COMMENT and comment.get("user", {}).get("id") in contributor_ids - signed_ids
if any(line.strip(SIGN_STRIP).casefold() == SIGN_TEXT for line in (comment.get("body") or "").splitlines())
and comment.get("user", {}).get("id") in contributor_ids - signed_ids
}
if records:
_persist(ledger_action, list(records.values()), action, number)
+1 -1
View File
@@ -17,7 +17,7 @@ permissions:
jobs:
CLA:
if: github.event_name == 'pull_request_target' || (github.event.issue.pull_request && (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I sign the CLA'))
if: github.event_name == 'pull_request_target' || (github.event.issue.pull_request && (contains(github.event.comment.body, 'recheck') || contains(github.event.comment.body, 'I have read the CLA Document and I sign the CLA')))
concurrency:
group: cla-${{ github.event.pull_request.number || github.event.issue.number }}
runs-on: ubuntu-latest
+15 -5
View File
@@ -172,12 +172,15 @@ def test_persist_surfaces_final_exhausted_error(monkeypatch, statuses, message):
assert store.put.call_count == len(statuses)
def test_run_records_exact_sentence_and_updates_legacy_comment():
"""Persist an exact signature and reuse the legacy action's status comment."""
@pytest.mark.parametrize(
"body", [cla.SIGN_COMMENT, f"{cla.SIGN_COMMENT}\r\n", f"{cla.SIGN_COMMENT} ", cla.SIGN_COMMENT.lower()]
)
def test_run_records_exact_sentence_and_updates_legacy_comment(body):
"""Persist a signature despite trailing whitespace or casing."""
source, store = action(), action()
signing = {
"id": 30,
"body": cla.SIGN_COMMENT,
"body": body,
"created_at": "date",
"user": {"id": 2, "login": "new", "type": "User"},
}
@@ -217,9 +220,16 @@ def test_run_stays_silent_when_all_contributors_already_signed():
source.patch.assert_not_called()
@pytest.mark.parametrize("body", [f"{cla.SIGN_COMMENT}!", cla.SIGN_COMMENT.lower(), f" {cla.SIGN_COMMENT}"])
@pytest.mark.parametrize(
"body",
[
f"could I write {cla.SIGN_COMMENT}?",
f"> {cla.SIGN_COMMENT}",
f'- **Sign the CLA**: sign by writing "{cla.SIGN_COMMENT}" in a new message.',
],
)
def test_run_rejects_similar_sentence_and_keeps_hard_failure(body):
"""Reject a modified signing sentence and leave the CLA gate failed."""
"""Reject a quoted or embedded sentence and leave the CLA gate failed."""
source, store = action(), action()
user = {"id": 2, "login": "new", "type": "User"}
source.get.side_effect = [