Skip to content

Commit 4ef30f2

Browse files
committed
Use only PRs to our repository in pr_info on push
1 parent d4c5174 commit 4ef30f2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/ci/pr_info.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
import json
33
import os
4-
from typing import Set
4+
from typing import Dict, List, Set
55

66
from unidiff import PatchSet # type: ignore
77

@@ -42,15 +42,22 @@ def get_pr_for_commit(sha, ref):
4242
try:
4343
response = get_with_retries(try_get_pr_url, sleep=RETRY_SLEEP)
4444
data = response.json()
45+
our_prs = [] # type: List[Dict]
4546
if len(data) > 1:
4647
print("Got more than one pr for commit", sha)
4748
for pr in data:
49+
# We need to check if the PR is created in our repo, because
50+
# https://github.com/kaynewu/ClickHouse/pull/2
51+
# has broke our PR search once in a while
52+
if pr["base"]["repo"]["full_name"] != GITHUB_REPOSITORY:
53+
continue
4854
# refs for pushes looks like refs/head/XX
4955
# refs for RPs looks like XX
5056
if pr["head"]["ref"] in ref:
5157
return pr
58+
our_prs.append(pr)
5259
print("Cannot find PR with required ref", ref, "returning first one")
53-
first_pr = data[0]
60+
first_pr = our_prs[0]
5461
return first_pr
5562
except Exception as ex:
5663
print("Cannot fetch PR info from commit", ex)

0 commit comments

Comments
 (0)