Created
March 3, 2015 05:41
-
-
Save arvinsim/8549793fc461416d11a8 to your computer and use it in GitHub Desktop.
A hacky script to get the remote origins of the git repositories of in the current directory
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 os | |
import subprocess | |
import re | |
currentdir = os.getcwd() | |
filename = currentdir + "/git_submodule_commands.sh" | |
pattern = re.compile("(?P<push_url>Push\s+URL):\s+(?P<url>https.*)") | |
# Check if file exists. If it does, delete it. | |
if os.path.isfile(filename): | |
os.remove(filename) | |
f = open(filename, 'a') | |
for dirname in os.listdir(currentdir): | |
if os.path.isdir(dirname): | |
print "in " + dirname + "..." | |
os.chdir(currentdir + "/" + dirname) | |
output = subprocess.check_output(["git", "remote", "show", "origin"]) | |
result = pattern.search(output) | |
if result is not None: | |
g = result.groupdict() | |
f.write(g['url'] + '\n') | |
os.chdir(currentdir) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment