Skip to content

Commit b727977

Browse files
committed
[gardening][py] Reduce indentation by creating an early exit.
1 parent 829ff3d commit b727977

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

utils/update-checkout

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,37 +66,39 @@ def obtain_additional_swift_sources(
6666
print("--- Skipping '" + dir_name + "' ---")
6767
continue
6868

69-
if not os.path.isdir(os.path.join(dir_name, ".git")):
70-
print("--- Cloning '" + dir_name + "' ---")
71-
72-
# If we have a url override, use that url instead of
73-
# interpolating.
74-
if 'url' in repo_info:
75-
remote = repo_info['url']
76-
elif with_ssh is True or 'https-clone-pattern' not in config:
77-
remote = config['ssh-clone-pattern'] % repo
78-
else:
79-
remote = config['https-clone-pattern'] % repo
80-
if skip_history:
81-
shell.call(['git', 'clone', '--recursive', '--depth', '1',
82-
remote, dir_name], echo=False)
69+
if os.path.isdir(os.path.join(dir_name, ".git")):
70+
continue
71+
72+
print("--- Cloning '" + dir_name + "' ---")
73+
74+
# If we have a url override, use that url instead of
75+
# interpolating.
76+
if 'url' in repo_info:
77+
remote = repo_info['url']
78+
elif with_ssh is True or 'https-clone-pattern' not in config:
79+
remote = config['ssh-clone-pattern'] % repo
80+
else:
81+
remote = config['https-clone-pattern'] % repo
82+
if skip_history:
83+
shell.call(['git', 'clone', '--recursive', '--depth', '1',
84+
remote, dir_name], echo=False)
85+
else:
86+
shell.call(['git', 'clone', '--recursive', remote,
87+
dir_name], echo=False)
88+
if branch:
89+
for config_branch_name in config['branch-names']:
90+
if branch not in config[config_branch_name]['aliases']:
91+
continue
92+
repo_branch = \
93+
config[config_branch_name]['repos'][dir_name]
94+
break
8395
else:
84-
shell.call(['git', 'clone', '--recursive', remote,
85-
dir_name], echo=False)
86-
if branch:
87-
for config_branch_name in config['branch-names']:
88-
if branch not in config[config_branch_name]['aliases']:
89-
continue
90-
repo_branch = \
91-
config[config_branch_name]['repos'][dir_name]
92-
break
93-
else:
94-
repo_branch = branch
95-
src_path = os.path.join(SWIFT_SOURCE_ROOT, dir_name,
96-
".git")
97-
shell.call(['git', '--git-dir', src_path, '--work-tree',
98-
os.path.join(SWIFT_SOURCE_ROOT, dir_name),
99-
'checkout', repo_branch], echo=False)
96+
repo_branch = branch
97+
src_path = os.path.join(SWIFT_SOURCE_ROOT, dir_name,
98+
".git")
99+
shell.call(['git', '--git-dir', src_path, '--work-tree',
100+
os.path.join(SWIFT_SOURCE_ROOT, dir_name),
101+
'checkout', repo_branch], echo=False)
100102

101103

102104
def validate_config(config):

0 commit comments

Comments
 (0)