@@ -93,13 +93,16 @@ def setup_git_ubuntu_user_services_dir(user: str, home_dir: str) -> bool:
9393 return _mkdir_for_user_with_error_checking (services_dir , user )
9494
9595
96- def refresh_git_ubuntu_source (user : str , home_dir : str , source_url : str ) -> bool :
96+ def refresh_git_ubuntu_source (
97+ user : str , home_dir : str , source_url : str , https_proxy : str = ""
98+ ) -> bool :
9799 """Clone or update the git-ubuntu git repo in the home directory.
98100
99101 Args:
100102 user: The user to run git clone as.
101103 home_dir: The home directory for the user.
102104 source_url: git-ubuntu's git repo url.
105+ https_proxy: The https proxy URL if required.
103106
104107 Returns:
105108 True if the clone succeeded, False otherwise.
@@ -122,15 +125,23 @@ def refresh_git_ubuntu_source(user: str, home_dir: str, source_url: str) -> bool
122125 return False
123126
124127 # Run git pull to get up to date
125- if not _run_command_as_user (user , f"git -C { clone_dir .as_posix ()} pull" ):
128+ pull_command = f"git -C { clone_dir .as_posix ()} pull"
129+ if https_proxy != "" :
130+ pull_command = f"https_proxy={ https_proxy } { pull_command } "
131+
132+ if not _run_command_as_user (user , pull_command ):
126133 logger .error ("Failed to update existing git-ubuntu source." )
127134 return False
128135
129136 return True
130137
131138 # Clone the repository
139+ clone_command = f"git clone { source_url } { clone_dir .as_posix ()} "
140+ if https_proxy != "" :
141+ clone_command = f"https_proxy={ https_proxy } { clone_command } "
142+
132143 logger .info ("Cloning git-ubuntu source to %s" , clone_dir .as_posix ())
133- if not _run_command_as_user (user , f"git clone { source_url } { clone_dir . as_posix () } " ):
144+ if not _run_command_as_user (user , clone_command ):
134145 logger .error ("Failed to clone git-ubuntu source." )
135146 return False
136147
0 commit comments