Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cgundy committed Dec 9, 2024
1 parent e7a5414 commit 20307ad
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions reusable_workflows/check_cla/check_cla_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,30 @@
APPROVED_LABEL = "cla:agreed"
GH_WORKFLOW_LABEL = "cla:gh-wf-pending"

# keep all old bot names for backwards compatibility
CLA_BOT_NAMES = ["cla-idx-bot[bot]", "sa-github-api", "dfinity-droid-prod[bot]"]


class CLAHandler:
def __init__(self, gh: github3.login) -> None:
self.cla_repo = gh.repository(owner="dfinity", repository="cla")
self.cla_link = f"{self.cla_repo.html_url}/blob/main/CLA.md"

@staticmethod
def check_comment_already_exists(
self, comments: github3.structs.GitHubIterator
search_comment: str, comments: github3.structs.GitHubIterator
) -> bool:
for comment in comments:
if comment.user.login in CLA_BOT_NAMES:
if search_comment == comment.body:
return True
return False

def comment_on_issue(self, issue: GHIssue):
def leave_failed_comment_on_issue(self, issue: GHIssue) -> None:
# check if bot has already left a message to avoid spam
issue_comments = issue.comments()
bot_comment = self.check_comment_already_exists(issue_comments)
if not bot_comment:
if not self.check_comment_already_exists(messages.FAILED_COMMENT, issue_comments):
issue.create_comment(messages.FAILED_COMMENT)

def comment_on_pr(self, pr: GHPullRequest, pr_comment):
bot_comment = self.check_comment_already_exists(pr.issue_comments())
if not bot_comment:
def comment_on_pr(self, pr: GHPullRequest, pr_comment: str) -> None:
pr_comments = pr.comments()
if not self.check_comment_already_exists(pr_comment, pr_comments):
pr.create_comment(pr_comment)

def check_if_cla_signed(self, issue: GHIssue, user: str) -> bool:
Expand Down

0 comments on commit 20307ad

Please sign in to comment.