Created
May 24, 2013 16:02
-
-
Save eden/5644530 to your computer and use it in GitHub Desktop.
Find dirty git repos in 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 stat | |
import os | |
for f in os.listdir("."): | |
if stat.S_ISDIR(os.stat(f).st_mode): | |
if not os.path.isdir(f + "/.git"): | |
continue | |
os.chdir(f) | |
sin, sout, serr = os.popen3("git branch") | |
branches = [b for b in map(str.strip, sout.readlines()) if b != "* master"] | |
sin, sout, serr = os.popen3("git ls-files --other --exclude-standard") | |
status = map(str.strip, sout.readlines()) | |
if len(branches) > 0 or len(status) > 0: | |
print "%s: %s; %d" % (f, ",".join(branches), len(status)) | |
os.chdir("..") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment