Skip to content

Instantly share code, notes, and snippets.

@thurask
Last active May 25, 2022 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thurask/357c70922ba77eef24641eac4b569548 to your computer and use it in GitHub Desktop.
Save thurask/357c70922ba77eef24641eac4b569548 to your computer and use it in GitHub Desktop.
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