Skip to content

Instantly share code, notes, and snippets.

@samueljackson92
Created June 22, 2017 07:46
Show Gist options
  • Save samueljackson92/9157110ad573923ef355ca2de372f25a to your computer and use it in GitHub Desktop.
Save samueljackson92/9157110ad573923ef355ca2de372f25a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import subprocess
import os
import re
import tempfile
def run_command(command):
try:
return subprocess.check_output(command.split(' ')).strip()
except Exception:
pass
def get_branch_name():
return run_command('git rev-parse --abbrev-ref HEAD')
def get_submodules():
with open('.gitmodules', 'r') as f:
lines = filter(lambda line: 'path' in line, f.readlines())
lines = [line.replace('path =', '').strip() for line in lines]
return lines
if __name__ == "__main__":
command = sys.argv[1]
current_folder = os.getcwd()
print current_folder, run_command(command)
for folder in get_submodules():
new_folder = os.path.join(current_folder, folder)
os.chdir(new_folder)
print new_folder, run_command(command)
os.chdir(current_folder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment