Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.
Open
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
24 changes: 24 additions & 0 deletions tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,3 +527,27 @@ def test_failed_change_at_head(self):
self.assertNotIn('merge', A.labels)
self.assertNotIn('merge', B.labels)
self.assertNotIn('merge', C.labels)

def test_multiple_pulls(self):
self.worker.hold_jobs_in_build = True
self.create_branch('org/project', 'pr_branch_A')
self.create_branch('org/project', 'pr_branch_B')
A = self.fake_github.openFakePullRequest('org/project', 'pr_branch_A',
'A')
B = self.fake_github.openFakePullRequest('org/project', 'pr_branch_B',
'B')
self.fake_github.emitEvent(A.getPullRequestOpenedEvent())
self.fake_github.emitEvent(B.getPullRequestOpenedEvent())
self.waitUntilSettled()

self.worker.hold_jobs_in_build = False
self.worker.release()
self.waitUntilSettled()
self.fake_github.emitEvent(A.addLabel('merge'))
self.fake_github.emitEvent(B.addLabel('merge'))
self.waitUntilSettled()

self.assertThat(A.comments[0],
MatchesRegex('.*Multiple pulls.*', re.DOTALL))
self.assertThat(B.comments[0],
MatchesRegex('.*Multiple pulls.*', re.DOTALL))
4 changes: 4 additions & 0 deletions zuul/connection/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ def getPullBySha(self, sha):
pulls.append(pr.as_dict())

if len(pulls) > 1:
for pull in pulls:
self.commentPull(pull.owner, pull.project, pull.pr_number,
'Multiple pulls found with head sha %s. '
'Please amend your change.' % sha)
raise Exception('Multiple pulls found with head sha %s' % sha)

log_rate_limit(self.log, github)
Expand Down