File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env python3
2
2
import json
3
3
import os
4
- from typing import Set
4
+ from typing import Dict , List , Set
5
5
6
6
from unidiff import PatchSet # type: ignore
7
7
@@ -42,15 +42,22 @@ def get_pr_for_commit(sha, ref):
42
42
try :
43
43
response = get_with_retries (try_get_pr_url , sleep = RETRY_SLEEP )
44
44
data = response .json ()
45
+ our_prs = [] # type: List[Dict]
45
46
if len (data ) > 1 :
46
47
print ("Got more than one pr for commit" , sha )
47
48
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
48
54
# refs for pushes looks like refs/head/XX
49
55
# refs for RPs looks like XX
50
56
if pr ["head" ]["ref" ] in ref :
51
57
return pr
58
+ our_prs .append (pr )
52
59
print ("Cannot find PR with required ref" , ref , "returning first one" )
53
- first_pr = data [0 ]
60
+ first_pr = our_prs [0 ]
54
61
return first_pr
55
62
except Exception as ex :
56
63
print ("Cannot fetch PR info from commit" , ex )
You can’t perform that action at this time.
0 commit comments