Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch_worker: Check pr.user.login for relevant pr #14

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kernel_patches_daemon/branch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,13 @@ def _is_relevant_pr(self, pr: PullRequest) -> bool:
"""
src_user = none_throws(pr.head.user).login
tgt_user = none_throws(pr.base.user).login
pr_user = none_throws(pr.user).login
tgt_branch = pr.base.ref
state = pr.state
if (
src_user == self.user_or_org
and tgt_user == self.user_or_org
and pr_user == self.user_login
and tgt_branch == self.repo_pr_base_branch
and state == "open"
):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_branch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,10 @@ def test_relevant_pr(self) -> None:

# Set our user login name
self._bw.user_or_org = user_login
self._bw.user_login = user_login

def make_munch(
user: str = user_login,
head_user: str = user_login,
base_user: str = user_login,
base_ref: str = TEST_REPO_PR_BASE_BRANCH,
Expand All @@ -334,6 +336,7 @@ def make_munch(
"""Helper to make a Munch that can be consumed as a PR (e.g accessing nested attributes)"""
return munchify(
{
"user": {"login": user},
"head": {"user": {"login": head_user}},
"base": {"user": {"login": base_user}, "ref": base_ref},
"state": state,
Expand All @@ -352,6 +355,11 @@ class TestCase:
pr=make_munch(),
relevant=True,
),
TestCase(
name="Wrong user",
pr=make_munch(user="bar"),
relevant=False,
),
TestCase(
name="Wrong head user",
pr=make_munch(head_user="bar"),
Expand Down