Skip to content

Commit

Permalink
branch_worker: Check pr.user.login for relevant pr
Browse files Browse the repository at this point in the history
When a PR is created from a different branch (instead of a fork), we see
pr['head']'user']['login'] and pr['base']['user']['login'] are both
"kernel-patches", but pr['user']['login'] is different. Such PR should not
be considered as relevant. Add a check to cover this case.

Signed-off-by: Song Liu <song@kernel.org>
  • Loading branch information
liu-song-6 committed Jan 18, 2024
1 parent 4de1f6d commit 8dd9457
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
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
2 changes: 2 additions & 0 deletions tests/test_branch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ 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(
head_user: str = user_login,
Expand All @@ -334,6 +335,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_login},
"head": {"user": {"login": head_user}},
"base": {"user": {"login": base_user}, "ref": base_ref},
"state": state,
Expand Down

0 comments on commit 8dd9457

Please sign in to comment.