From f47d09496ae3e241ea45fed7e3d9612b2eda2f3f Mon Sep 17 00:00:00 2001 From: johntito Date: Wed, 6 Nov 2024 10:34:43 +0800 Subject: [PATCH] Add "--depth" and "-b" arguments for git clone command - Added --depth 1 option to reduce clone time. - Added -b option to reduce clone time. --- litex_setup.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/litex_setup.py b/litex_setup.py index 998d330ae..41f762fc4 100755 --- a/litex_setup.py +++ b/litex_setup.py @@ -216,10 +216,19 @@ def litex_setup_init_repos(config="standard", tag=None, dev_mode=False): repo_url = repo.url if dev_mode: repo_url = repo_url.replace("https://github.com/", "git@github.com:") + + clone_options = ["--depth 1"] + if repo.clone == "recursive": + clone_options.append("--recursive") + if repo.branch is not None: + clone_options.append(f"-b {repo.branch}") + options_str = " ".join(clone_options) + subprocess.check_call("git clone {url} {options}".format( url = repo_url + name + ".git", - options = "--recursive" if repo.clone == "recursive" else "" + options = options_str ), shell=True) + os.chdir(os.path.join(current_path, name)) # Use specific Branch. subprocess.check_call("git checkout " + repo.branch, shell=True) @@ -490,4 +499,3 @@ def main(): if __name__ == "__main__": main() -