Last active
December 18, 2015 02:29
-
-
Save matthewmayer/5711274 to your computer and use it in GitHub Desktop.
Check if all your git repos are synced with a server
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/python | |
import glob | |
import os | |
import subprocess | |
folders = glob.glob("*") | |
for f in folders: | |
if os.path.isdir(f): | |
config = f+"/.git/config" | |
if not os.path.exists(config): | |
print "%s appears not to be a Git repo" % f | |
else: | |
configdata = open(config).read() | |
sips = subprocess.Popen(["git","status"], stdout=subprocess.PIPE,cwd=f) | |
output = sips.stdout.read() | |
if "working directory clean" not in output: | |
print "%s has uncommitted changes" % f | |
elif "Your branch is" in output: | |
print "%s has unpushed changes" % f | |
elif "[remote \"origin\"]" not in configdata: | |
print "%s has no configured origin" % f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment