Skip to content

Commit 6d6c59c

Browse files
authored
Merge pull request #4669 from apple/update_checkout_cross_repo
[Utils] Cherry pick fix for cross repo pull request testing
2 parents 89ce5b1 + 0823840 commit 6d6c59c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

utils/update-checkout

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ from swift_build_support import shell # noqa (E402)
3535

3636

3737
def update_single_repository(repo_path, branch, reset_to_remote, should_clean,
38-
cross_repos_pr):
38+
cross_repo):
3939
if not os.path.isdir(repo_path):
4040
return
4141

@@ -68,15 +68,15 @@ def update_single_repository(repo_path, branch, reset_to_remote, should_clean,
6868

6969
# If we were asked to reset to the specified branch, do the hard
7070
# reset and return.
71-
if reset_to_remote:
71+
if reset_to_remote and not cross_repo:
7272
shell.call(['git', 'reset', '--hard', "origin/%s" % branch],
7373
echo=True)
7474
return
7575

7676
# Prior to Git 2.6, this is the way to do a "git pull
7777
# --rebase" that respects rebase.autostash. See
7878
# http://stackoverflow.com/a/30209750/125349
79-
if not cross_repos_pr:
79+
if not cross_repo:
8080
shell.call(["git", "rebase", "FETCH_HEAD"], echo=True)
8181
shell.call(["git", "submodule", "update", "--recursive"],
8282
echo=True)
@@ -85,6 +85,7 @@ def update_single_repository(repo_path, branch, reset_to_remote, should_clean,
8585
def update_all_repositories(args, config, scheme_name, cross_repos_pr):
8686
repo_branch = scheme_name
8787
for repo_name in config['repos'].keys():
88+
cross_repo = False
8889
if repo_name in args.skip_repository_list:
8990
print("--- Skipping '" + repo_name + "' ---")
9091
continue
@@ -100,9 +101,12 @@ def update_all_repositories(args, config, scheme_name, cross_repos_pr):
100101
repo_branch = v['repos'][repo_name]
101102
remote_repo_id = config['repos'][repo_name]['remote']['id']
102103
if remote_repo_id in cross_repos_pr:
104+
cross_repo = True
103105
pr_id = cross_repos_pr[remote_repo_id]
104106
repo_branch = "ci_pr_{0}".format(pr_id)
105107
with shell.pushd(repo_path, dry_run=False, echo=False):
108+
shell.call(["git", "checkout", v['repos'][repo_name]],
109+
echo=True)
106110
shell.capture(["git", "branch", "-D", repo_branch],
107111
echo=True, allow_non_zero_exit=True)
108112
shell.call(["git", "fetch", "origin",
@@ -113,7 +117,7 @@ def update_all_repositories(args, config, scheme_name, cross_repos_pr):
113117
repo_branch,
114118
args.reset_to_remote,
115119
args.clean,
116-
cross_repos_pr)
120+
cross_repo)
117121

118122

119123
def obtain_additional_swift_sources(
@@ -252,8 +256,10 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
252256

253257
cross_repos_pr = {}
254258
if github_comment:
255-
repos_with_pr = re.findall(r'apple/[-a-zA-Z0-9_]+#\d+', github_comment)
259+
regex_pr = r'(apple/[-a-zA-Z0-9_]+/pull/\d+|apple/[-a-zA-Z0-9_]+#\d+)'
260+
repos_with_pr = re.findall(regex_pr, github_comment)
256261
print("Found related pull requests:", str(repos_with_pr))
262+
repos_with_pr = [pr.replace('/pull/','#') for pr in repos_with_pr]
257263
cross_repos_pr = dict(pr.split('#') for pr in repos_with_pr)
258264

259265
if clone or clone_with_ssh:

utils/update-checkout-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"clang": {
88
"remote": { "id": "apple/swift-clang" } },
99
"swift": {
10-
"remote": { "id": "apple/swift-swift" } },
10+
"remote": { "id": "apple/swift" } },
1111
"lldb": {
1212
"remote": { "id": "apple/swift-lldb" } },
1313
"cmark": {

0 commit comments

Comments
 (0)