From ec8e3e491ea548ba298831fd6a525b29436c5fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Mon, 7 Oct 2024 16:32:49 +0200 Subject: [PATCH] Don't check merge base branch --- nixprstatus/pr.py | 7 +++++++ pyproject.toml | 2 +- tests/test_pr.py | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/nixprstatus/pr.py b/nixprstatus/pr.py index faace8c..6eb0bc5 100644 --- a/nixprstatus/pr.py +++ b/nixprstatus/pr.py @@ -58,6 +58,13 @@ def pr_merge_status( results = {} + # Check if base branch is in our list, if it is + # no need to call commit_in_branch + merge_base_branch = pr_data.get("base", {}).get("ref") + if merge_base_branch in branches: + results[merge_base_branch] = True + branches.remove(merge_base_branch) + for branch in branches: in_branch = commit_in_branch(commit_sha, branch) results[branch] = in_branch diff --git a/pyproject.toml b/pyproject.toml index 1a3b8c6..e9c46c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nixprstatus" -version = "0.1.2" +version = "0.1.3" description = "Nixpkgs PR status checker" authors = ["Torjus HÃ¥kestad "] license = "MIT" diff --git a/tests/test_pr.py b/tests/test_pr.py index 3e81f7d..27ab5ce 100644 --- a/tests/test_pr.py +++ b/tests/test_pr.py @@ -66,6 +66,19 @@ class TestPRMergeStatus(unittest.TestCase): res = pr_merge_status(pr, branches, check_backport=True) self.assertEqual(res.title, expected_title) + @unittest.mock.patch("requests.get", side_effect=mocked_requests_get) + def test_pr_merge_status_no_check_master_345583(self, mock_get): + pr = 345583 + branches = ["master", "nixos-unstable", "nixos-24.05"] + master_compare_url = "https://api.github.com/repos/NixOS/nixpkgs/compare/master...2c5fac3edf2d00d948253e392ec1604b29b38f14" + + res = pr_merge_status(pr, branches, check_backport=False) + self.assertTrue(res.merged) + self.assertTrue(res.branches["master"]) + + urls_called = [call[0][0] for call in mock_get.call_args_list] + self.assertFalse(master_compare_url in urls_called) + class TestCommitInBranch(unittest.TestCase): @unittest.mock.patch("requests.get", side_effect=mocked_requests_get) -- 2.45.2