Skip to content

Commit

Permalink
Merge pull request #61 from gbrindisi/fix-dup-pr
Browse files Browse the repository at this point in the history
Fixed failed check for duplicate pull request
  • Loading branch information
zkoppert authored Feb 26, 2024
2 parents f20d2da + 55a2bd8 commit b6e56d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion evergreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,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
Expand Down
8 changes: 3 additions & 5 deletions test_evergreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit b6e56d1

Please sign in to comment.