Get changed files using gitpython
for item in repo.index.diff(None): print item.a_path
or to get just the list:
changedFiles = [ item.a_path for item in repo.index.diff(None) ]
repo.index.diff() returns git.diff.Diffable described in http://gitpython.readthedocs.io/en/stable/reference.html#module-git.diff
So function can look like this:
def get_status(repo, path): changed = [ item.a_path for item in repo.index.diff(None) ] if path in repo.untracked_files: return 'untracked' elif path in changed: return 'modified' else: return 'don''t care'