def _clone_github_repo()

in eng/scripts/build_api_docs.py [0:0]


def _clone_github_repo(path, *, ref = None, pod_install = True):
    # clone the repo into the build folder so it can easily be removed
    repo_name = os.path.split(path)[-1]
    branch_arg = f"--branch {ref}" if ref else ""
    clone_dir = f"build/{repo_name}"
    if os.path.exists(clone_dir):
        _run(f"rm -rf {clone_dir}")

    _run(f"git clone {path} build/{repo_name} --depth 1 {branch_arg} --single-branch")

    if pod_install:
        try:
            # find the podfile and run pod install
            podfile_path = glob.glob(os.path.abspath(os.path.join(".", "build", repo_name, "**", "Podfile")))[0]
            podfile_dir = os.path.split(podfile_path)[0]
            stdout, stderr = _run(f"pod install --project-directory={podfile_dir}")
            print(stdout)
        except:
            _log_warning("Podfile not found. Attempting to generate docs without pod install...")