From faece68ffd7491c7f2c1c247bdb96250c43869cc Mon Sep 17 00:00:00 2001 From: Carly Gundy <47304080+cgundy@users.noreply.github.com> Date: Tue, 21 Nov 2023 13:39:56 +0100 Subject: [PATCH 1/3] Update pending label --- reusable_workflows/check_cla/check_cla_pr.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/reusable_workflows/check_cla/check_cla_pr.py b/reusable_workflows/check_cla/check_cla_pr.py index 75df967..ec3154f 100644 --- a/reusable_workflows/check_cla/check_cla_pr.py +++ b/reusable_workflows/check_cla/check_cla_pr.py @@ -73,19 +73,20 @@ def create_cla_issue(self, user: str) -> GHIssue: ), ) # replace with PENDING, once new bot has been released - issue.add_labels(GH_WORKFLOW_LABEL) + issue.add_labels(PENDING_LABEL) return issue def handle_cla_signed(self, issue: GHIssue, user: str) -> None: for label in issue.original_labels: if label.name == APPROVED_LABEL: return - elif label.name == GH_WORKFLOW_LABEL: - agreement_message = messages.AGREED_MESSAGE.format(user) - issue.create_comment(agreement_message) - issue.remove_label(GH_WORKFLOW_LABEL) - issue.add_labels(APPROVED_LABEL) - return + for pending_label in [GH_WORKFLOW_LABEL, PENDING_LABEL]: + if label.name == pending_label: + agreement_message = messages.AGREED_MESSAGE.format(user) + issue.create_comment(agreement_message) + issue.remove_label(pending_label) + issue.add_labels(APPROVED_LABEL) + return print( "No cla labels found - manually check the cla issue to see what state it is in. Exiting program." # noqa ) From 59361ac7f7a8c9104e1b175a2bfedcbfa9d690b7 Mon Sep 17 00:00:00 2001 From: Carly Gundy Date: Wed, 22 Nov 2023 08:47:38 +0100 Subject: [PATCH 2/3] add tests --- reusable_workflows/tests/test_cla_pr.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/reusable_workflows/tests/test_cla_pr.py b/reusable_workflows/tests/test_cla_pr.py index 7eed40a..2344eda 100644 --- a/reusable_workflows/tests/test_cla_pr.py +++ b/reusable_workflows/tests/test_cla_pr.py @@ -142,6 +142,7 @@ def test_create_cla_issue(): "cla: @username", body=cla_agreement_message, ) + issue.add_labels.assert_called_with("cla:pending") def test_handle_cla_signed_with_agreed_label(): @@ -171,6 +172,19 @@ def test_handle_cla_signed_with_pending_label(): issue.remove_label.assert_called_once() issue.add_labels.assert_called_once() +def test_handle_cla_signed_with_new_pending_label(): + issue = mock.Mock() + label = mock.Mock() + label.name = "cla:pending" + issue.original_labels = [label] + agreement_message = AGREED_MESSAGE.format("username") + + cla = CLAHandler(mock.Mock()) + cla.handle_cla_signed(issue, "username") + + issue.create_comment.assert_called_with(agreement_message) + issue.remove_label.assert_called_once() + issue.add_labels.assert_called_once() def test_handle_cla_signed_with_no_label(capfd): issue = mock.Mock() From 64b83b252969d8175f01d21277695a2e4e2353e8 Mon Sep 17 00:00:00 2001 From: Carly Gundy <47304080+cgundy@users.noreply.github.com> Date: Wed, 22 Nov 2023 09:56:15 +0100 Subject: [PATCH 3/3] remove comment --- reusable_workflows/check_cla/check_cla_pr.py | 1 - 1 file changed, 1 deletion(-) diff --git a/reusable_workflows/check_cla/check_cla_pr.py b/reusable_workflows/check_cla/check_cla_pr.py index ec3154f..efc2752 100644 --- a/reusable_workflows/check_cla/check_cla_pr.py +++ b/reusable_workflows/check_cla/check_cla_pr.py @@ -72,7 +72,6 @@ def create_cla_issue(self, user: str) -> GHIssue: user, self.cla_link, user_agreement_message ), ) - # replace with PENDING, once new bot has been released issue.add_labels(PENDING_LABEL) return issue