Skip to content

Commit

Permalink
Merge pull request #112 from LinkTagCo/bot
Browse files Browse the repository at this point in the history
Do not invite bots.
  • Loading branch information
pquentin authored Jul 6, 2020
2 parents 1013a7b + 34aaed8 commit 43e8e6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions snekomatic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ async def pull_request_merged(event_type, payload, gh_client):
if not glom(payload, "pull_request.merged"):
print("but not merged, so never mind")
return
if glom(payload, "pull_request.user.type", default="").lower() == "bot":
print("This user is a bot -> not inviting")
return
creator = glom(payload, "pull_request.user.login")
org = glom(payload, "organization.login")
print(f"PR by {creator} was merged!")
Expand Down
11 changes: 10 additions & 1 deletion tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class InviteScenario:
member_state = attr.ib()
expect_in_db_after = attr.ib()
expect_invite = attr.ib()
user_type = attr.ib(default="User")


INVITE_SCENARIOS = [
Expand Down Expand Up @@ -76,6 +77,14 @@ class InviteScenario:
expect_in_db_after=True,
expect_invite=True,
),
InviteScenario(
pr_merged=True,
in_db=False,
member_state=None,
expect_in_db_after=False,
expect_invite=False,
user_type="Bot",
),
]


Expand All @@ -101,7 +110,7 @@ async def test_invite_scenarios(s, our_app_url, monkeypatch):
"action": "closed",
"pull_request": {
"merged": s.pr_merged,
"user": {"login": PR_CREATOR},
"user": {"login": PR_CREATOR, "type": s.user_type},
"comments_url": "fake-comments-url",
},
"organization": {"login": ORG},
Expand Down

0 comments on commit 43e8e6d

Please sign in to comment.