@@ -25,12 +25,12 @@ def git_clone_repo(git_config, entry_point, source_dir=None, dependencies=None):
25
25
and set ``entry_point``, ``source_dir`` and ``dependencies`` to the right file or directory in the repo cloned.
26
26
27
27
Args:
28
- git_config (dict[str, str ]): Git configurations used for cloning files, including ``repo``, ``branch``,
28
+ git_config (dict[str, object ]): Git configurations used for cloning files, including ``repo``, ``branch``,
29
29
``commit``, ``2FA_enabled``, ``username``, ``password`` and ``token``. The fields are optional except
30
30
``repo``. If ``branch`` is not specified, master branch will be used. If ``commit`` is not specified,
31
31
the latest commit in the required branch will be used. ``2FA_enabled``, ``username``, ``password`` and
32
32
``token`` are for authentication purpose.
33
- ``2FA_enabled`` must be ' True' or ' False' if it is provided. If ``2FA_enabled`` is not provided, we
33
+ ``2FA_enabled`` must be `` True`` or `` False`` if it is provided. If ``2FA_enabled`` is not provided, we
34
34
consider 2FA as disabled. For GitHub and other Git repos, when ssh urls are provided, it does not make a
35
35
difference whether 2FA is enabled or disabled; an ssh passphrase should be in local storage. When
36
36
https urls are provided: if 2FA is disabled, then either token or username+password will be used for
@@ -97,14 +97,11 @@ def _validate_git_config(git_config):
97
97
if "repo" not in git_config :
98
98
raise ValueError ("Please provide a repo for git_config." )
99
99
for key in git_config :
100
- if key in git_config and not isinstance (git_config [key ], six .string_types ):
100
+ if key == "2FA_enabled" :
101
+ if not isinstance (git_config ["2FA_enabled" ], bool ):
102
+ raise ValueError ("Please enter a bool type for 2FA_enabled'." )
103
+ elif not isinstance (git_config [key ], six .string_types ):
101
104
raise ValueError ("'{}' must be a string." .format (key ))
102
- if (
103
- "2FA_enabled" in git_config
104
- and git_config ["2FA_enabled" ] != "True"
105
- and git_config ["2FA_enabled" ] != "False"
106
- ):
107
- raise ValueError ("Please enter 'True' or 'False' for 2FA_enabled'." )
108
105
109
106
110
107
def _generate_and_run_clone_command (git_config , dest_dir ):
@@ -140,7 +137,7 @@ def _clone_command_for_github_like(git_config, dest_dir):
140
137
raise ValueError ("Invalid Git url provided." )
141
138
if is_ssh :
142
139
_clone_command_for_github_like_ssh (git_config , dest_dir )
143
- elif "2FA_enabled" in git_config and git_config ["2FA_enabled" ] == " True" :
140
+ elif "2FA_enabled" in git_config and git_config ["2FA_enabled" ] is True :
144
141
_clone_command_for_github_like_https_2fa_enabled (git_config , dest_dir )
145
142
else :
146
143
_clone_command_for_github_like_https_2fa_disabled (git_config , dest_dir )
0 commit comments