@@ -25,12 +25,12 @@ def git_clone_repo(git_config, entry_point, source_dir=None, dependencies=None):
2525 and set ``entry_point``, ``source_dir`` and ``dependencies`` to the right file or directory in the repo cloned.
2626
2727 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``,
2929 ``commit``, ``2FA_enabled``, ``username``, ``password`` and ``token``. The fields are optional except
3030 ``repo``. If ``branch`` is not specified, master branch will be used. If ``commit`` is not specified,
3131 the latest commit in the required branch will be used. ``2FA_enabled``, ``username``, ``password`` and
3232 ``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
3434 consider 2FA as disabled. For GitHub and other Git repos, when ssh urls are provided, it does not make a
3535 difference whether 2FA is enabled or disabled; an ssh passphrase should be in local storage. When
3636 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):
9797 if "repo" not in git_config :
9898 raise ValueError ("Please provide a repo for git_config." )
9999 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 ):
101104 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'." )
108105
109106
110107def _generate_and_run_clone_command (git_config , dest_dir ):
@@ -140,7 +137,7 @@ def _clone_command_for_github_like(git_config, dest_dir):
140137 raise ValueError ("Invalid Git url provided." )
141138 if is_ssh :
142139 _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 :
144141 _clone_command_for_github_like_https_2fa_enabled (git_config , dest_dir )
145142 else :
146143 _clone_command_for_github_like_https_2fa_disabled (git_config , dest_dir )
0 commit comments