Created
May 29, 2015 14:06
-
-
Save aoloe/302f79e01f078093306d to your computer and use it in GitHub Desktop.
git status with dir from python
This file contains hidden or 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 | |
from sh import git | |
def subDirPath (d): | |
return filter(os.path.isdir, [os.path.join(d,f) for f in os.listdir(d)]) | |
curDir = os.getcwd() | |
curDir = "/home/ale/docs/src/" | |
for d in subDirPath(curDir) : | |
if os.path.isdir(os.path.join(d, ".git")) : | |
print(git("--git-dir="+os.path.join(d, ".git")+" --work-tree="+d+" status --porcelain")) | |
break | |
elif os.path.isdir(os.path.join(d, ".svn")) : | |
print("svn "+d) | |
""" | |
output: | |
RAN: '/usr/bin/git --git-dir=/home/ale/docs/src/scribus-manual-introduction/.git --work-tree=/home/ale/docs/src/scribus-manual-introduction status --porcelain' | |
STDOUT: | |
usage: git [--version] [--help] [-C <path>] [-c name=value] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment