Created
September 6, 2013 22:23
-
-
Save matthew-brett/6470792 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 os | |
from os.path import join as pjoin, isdir | |
import sys | |
import shutil | |
from subprocess import call | |
input_dir = '/Users/mb312/dev_trees' | |
output_dir = os.getcwd() | |
for dir in sorted(os.listdir(input_dir)): | |
if dir.startswith('.'): | |
continue | |
this_dir = pjoin(input_dir, dir) | |
if not isdir(this_dir): | |
continue | |
that_dir = pjoin(output_dir, dir) | |
if isdir(that_dir): | |
continue | |
print(this_dir) | |
if isdir(pjoin(this_dir, '.git')): | |
print('Cloning') | |
os.chdir(this_dir) | |
try: | |
call(['git', 'fetch', '--all']) | |
call(['git', 'tff']) | |
finally: | |
os.chdir(output_dir) | |
call(['git', 'clone', this_dir]) | |
else: | |
print('Copying') | |
shutil.copytree(this_dir, pjoin(output_dir, dir), symlinks=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Get all the repos on my machine, updating git repos