Created
September 4, 2015 10:44
-
-
Save javierarilos/b7892636dfe151c5202e to your computer and use it in GitHub Desktop.
Recursively enters into a directory subdirs and does git pull --rebase
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
#!/usr/bin/env python3 | |
""" | |
Recursively enters into a directory subdirs and does git pull --rebase | |
""" | |
import os | |
import sys | |
from subprocess import call | |
def ls_dirs(directory='.'): | |
return [os.path.join(directory, name) for name in os.listdir(directory) if os.path.isdir(os.path.join(directory, name))] | |
base_dir = (len(sys.argv) > 1 and sys.argv[1]) or '.' | |
dirs = ls_dirs(base_dir) | |
for dir in dirs: | |
os.chdir(dir) | |
print() | |
print('>>>>>>>>>>>>>>>> pulling:', dir) | |
result = call(['git', 'pull', '--rebase']) | |
if result != 0: | |
print('<<<<<<<<<<<<<<<< git pull was bad for:', dir) | |
else: | |
print('<<<<<<<<<<<<<<<< done:', dir) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment