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

Fixed failed check for duplicate pull request #61

Merged
merged 1 commit into from
Feb 26, 2024
Merged
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: 1 addition & 1 deletion evergreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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