Skip to content

Instantly share code, notes, and snippets.

@Esonhugh
Created February 14, 2025 13:32
Show Gist options
  • Select an option

  • Save Esonhugh/c059cd2c1914ea4b75be95a1795930ed to your computer and use it in GitHub Desktop.

Select an option

Save Esonhugh/c059cd2c1914ea4b75be95a1795930ed to your computer and use it in GitHub Desktop.

Revisions

  1. Esonhugh created this gist Feb 14, 2025.
    37 changes: 37 additions & 0 deletions cloner.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    import sys

    # usage: python cloner.py 1> cloner.sh 2> extract.sh
    #

    username = "user"
    password = "pass_or_token"
    domain = "github.com"

    Prefix = f"git clone --mirror https://{username}:{password}@{domain}/"

    REPOLIST_TXT= "repo_list" # filename contains lists of http/https urls on git

    def get_git_url(line_arr):
    return "/".join(line_arr[6:])

    def get_dir(line_arr):
    return "/".join(line_arr[6:])

    PrefixClone = f"git clone "
    ExtractedPrefix = "dec"


    with open(REPOLIST_TXT, "r") as f:
    line = "1"
    count = 1
    while line:
    line = f.readline().strip()
    line_arr = line.split("/")
    git_url = get_git_url(line_arr)
    dir = get_dir(line_arr)
    print(f"echo current is {count} repo {git_url} clone to {dir}")
    print(f"{Prefix}{git_url} {dir}")
    print(f"echo current is {count} local mirror repo {dir} Extracted to {ExtractedPrefix}/{dir}", file=sys.stderr)
    print(f"{PrefixClone} ./{dir} ./{ExtractedPrefix}/{dir}" ,file=sys.stderr)
    count+=1