diff --git a/evergreen.py b/evergreen.py index 59e617a..60a8253 100644 --- a/evergreen.py +++ b/evergreen.py @@ -190,7 +190,7 @@ def check_pending_pulls_for_duplicates(title, repo) -> bool: pull_requests = repo.pull_requests(state="open") skip = False for pull_request in pull_requests: - if pull_request.head.ref.startswith(title): + if pull_request.title.startswith(title): print("\tPull request already exists: " + pull_request.html_url) skip = True break diff --git a/test_evergreen.py b/test_evergreen.py index f5cfe22..a1e39d4 100644 --- a/test_evergreen.py +++ b/test_evergreen.py @@ -237,7 +237,7 @@ def test_check_pending_pulls_for_duplicates_no_duplicates(self): """Test the check_pending_pulls_for_duplicates function where there are no duplicates to be found.""" mock_repo = MagicMock() # Mock repo object mock_pull_request = MagicMock() - mock_pull_request.head.ref = "not-dependabot-branch" + mock_pull_request.title = "not-dependabot-branch" mock_repo.pull_requests.return_value = [mock_pull_request] result = check_pending_pulls_for_duplicates("dependabot-branch", mock_repo) @@ -249,12 +249,10 @@ def test_check_pending_pulls_for_duplicates_with_duplicates(self): """Test the check_pending_pulls_for_duplicates function where there are duplicates to be found.""" mock_repo = MagicMock() # Mock repo object mock_pull_request = MagicMock() - mock_pull_request.head.ref = "dependabot-branch" + mock_pull_request.title = "dependabot-branch" mock_repo.pull_requests.return_value = [mock_pull_request] - result = check_pending_pulls_for_duplicates( - mock_pull_request.head.ref, mock_repo - ) + result = check_pending_pulls_for_duplicates(mock_pull_request.title, mock_repo) # Assert that the function returned the expected result self.assertEqual(result, True)