@@ -35,7 +35,7 @@ from swift_build_support import shell # noqa (E402)
35
35
36
36
37
37
def update_single_repository (repo_path , branch , reset_to_remote , should_clean ,
38
- cross_repos_pr ):
38
+ cross_repo ):
39
39
if not os .path .isdir (repo_path ):
40
40
return
41
41
@@ -68,15 +68,15 @@ def update_single_repository(repo_path, branch, reset_to_remote, should_clean,
68
68
69
69
# If we were asked to reset to the specified branch, do the hard
70
70
# reset and return.
71
- if reset_to_remote :
71
+ if reset_to_remote and not cross_repo :
72
72
shell .call (['git' , 'reset' , '--hard' , "origin/%s" % branch ],
73
73
echo = True )
74
74
return
75
75
76
76
# Prior to Git 2.6, this is the way to do a "git pull
77
77
# --rebase" that respects rebase.autostash. See
78
78
# http://stackoverflow.com/a/30209750/125349
79
- if not cross_repos_pr :
79
+ if not cross_repo :
80
80
shell .call (["git" , "rebase" , "FETCH_HEAD" ], echo = True )
81
81
shell .call (["git" , "submodule" , "update" , "--recursive" ],
82
82
echo = True )
@@ -85,6 +85,7 @@ def update_single_repository(repo_path, branch, reset_to_remote, should_clean,
85
85
def update_all_repositories (args , config , scheme_name , cross_repos_pr ):
86
86
repo_branch = scheme_name
87
87
for repo_name in config ['repos' ].keys ():
88
+ cross_repo = False
88
89
if repo_name in args .skip_repository_list :
89
90
print ("--- Skipping '" + repo_name + "' ---" )
90
91
continue
@@ -100,9 +101,12 @@ def update_all_repositories(args, config, scheme_name, cross_repos_pr):
100
101
repo_branch = v ['repos' ][repo_name ]
101
102
remote_repo_id = config ['repos' ][repo_name ]['remote' ]['id' ]
102
103
if remote_repo_id in cross_repos_pr :
104
+ cross_repo = True
103
105
pr_id = cross_repos_pr [remote_repo_id ]
104
106
repo_branch = "ci_pr_{0}" .format (pr_id )
105
107
with shell .pushd (repo_path , dry_run = False , echo = False ):
108
+ shell .call (["git" , "checkout" , v ['repos' ][repo_name ]],
109
+ echo = True )
106
110
shell .capture (["git" , "branch" , "-D" , repo_branch ],
107
111
echo = True , allow_non_zero_exit = True )
108
112
shell .call (["git" , "fetch" , "origin" ,
@@ -113,7 +117,7 @@ def update_all_repositories(args, config, scheme_name, cross_repos_pr):
113
117
repo_branch ,
114
118
args .reset_to_remote ,
115
119
args .clean ,
116
- cross_repos_pr )
120
+ cross_repo )
117
121
118
122
119
123
def obtain_additional_swift_sources (
@@ -255,7 +259,7 @@ By default, updates your checkouts of Swift, SourceKit, LLDB, and SwiftPM.""")
255
259
regex_pr = r'(apple/[-a-zA-Z0-9_]+/pull/\d+|apple/[-a-zA-Z0-9_]+#\d+)'
256
260
repos_with_pr = re .findall (regex_pr , github_comment )
257
261
print ("Found related pull requests:" , str (repos_with_pr ))
258
- repos_with_pr = [pr .replace ('/pull/' ,'#' )for pr in repos_with_pr ]
262
+ repos_with_pr = [pr .replace ('/pull/' ,'#' ) for pr in repos_with_pr ]
259
263
cross_repos_pr = dict (pr .split ('#' ) for pr in repos_with_pr )
260
264
261
265
if clone or clone_with_ssh :
0 commit comments