Skip to content

Commit 8c721de

Browse files
committed
[update-checkout] Don't use env for portability.
env is not portable in systems that do not have env, like for example Windows. However, passing the environment is supported by shell.run using the env parameter, which should be portable. For some reason shell.run doesn't merge the environment with the current environment by default, so we do it externally to not modify other possible usages of the function.
1 parent cdffaf3 commit 8c721de

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

utils/update_checkout/update_checkout/update_checkout.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,29 +218,37 @@ def obtain_additional_swift_sources(pool_args):
218218
(args, repo_name, repo_info, repo_branch, remote, with_ssh, scheme_name,
219219
skip_history, skip_repository_list) = pool_args
220220

221+
env = dict(os.environ)
222+
env.update({'GIT_TERMINAL_PROMPT': 0})
223+
221224
with shell.pushd(SWIFT_SOURCE_ROOT, dry_run=False, echo=False):
222225

223226
print("Cloning '" + repo_name + "'")
224227

225228
if skip_history:
226-
shell.run(['env', 'GIT_TERMINAL_PROMPT=0', 'git', 'clone',
229+
shell.run(['git', 'clone',
227230
'--recursive', '--depth', '1', '--branch',
228231
repo_branch, remote, repo_name],
232+
env=env,
229233
echo=True)
230234
else:
231-
shell.run(['env', 'GIT_TERMINAL_PROMPT=0', 'git', 'clone',
235+
shell.run(['git', 'clone',
232236
'--recursive', remote, repo_name],
237+
env=env,
233238
echo=True)
234239
if scheme_name:
235240
src_path = os.path.join(SWIFT_SOURCE_ROOT, repo_name, ".git")
236-
shell.run(['env', 'GIT_TERMINAL_PROMPT=0', 'git', '--git-dir',
241+
shell.run(['git', '--git-dir',
237242
src_path, '--work-tree',
238243
os.path.join(SWIFT_SOURCE_ROOT, repo_name),
239-
'checkout', repo_branch], echo=False)
244+
'checkout', repo_branch],
245+
env=env,
246+
echo=False)
240247
with shell.pushd(os.path.join(SWIFT_SOURCE_ROOT, repo_name),
241248
dry_run=False, echo=False):
242-
shell.run(['env', 'GIT_TERMINAL_PROMPT=0', "git", "submodule",
249+
shell.run(["git", "submodule",
243250
"update", "--recursive"],
251+
env=env,
244252
echo=False)
245253

246254

0 commit comments

Comments
 (0)