Last active
May 25, 2022 19:57
-
-
Save thurask/357c70922ba77eef24641eac4b569548 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import concurrent.futures | |
import os | |
import subprocess | |
GITFOLDER = "C:\\git" | |
def filterer(infx): | |
dirs = [os.path.join(infx, x) for x in os.listdir(infx) if os.path.isdir(os.path.join(infx, x)) and ".git" in os.listdir(os.path.join(infx, x))] | |
return dirs | |
def single_puller(folder): | |
global dbg | |
pull_cmd = ["git", "-C", folder, "pull"] | |
submodule_cmd = ["git", "-C", folder, "submodule", "update", "--init", "--recursive"] | |
if dbg: | |
pull_cmd.append("-v") | |
submodule_cmd.append("-v") | |
qwe = subprocess.run(pull_cmd) | |
rty = subprocess.run(submodule_cmd) | |
if any([qwe.returncode, rty.returncode]): | |
print("ERROR: {}".format(folder)) | |
def puller(gits): | |
with concurrent.futures.ThreadPoolExecutor(max_workers=len(gits)) as exc: | |
exc.map(single_puller, gits) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--debug", "-d", dest="dbg", action="store_true", help="print folder name") | |
args = parser.parse_args() | |
dbg = args.dbg | |
gits = filterer(GITFOLDER) | |
puller(gits) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment