How to know if a git repository is clean with Python3 (pygit2)?
问题 I'm trying to determine if a or git commit is needed in a git repository. I come up with this code that works fine for me : def is_dirty(repo): import pygit2 status = repo.status() for filepath, flags in status.items(): if flags != pygit2.GIT_STATUS_CURRENT: if flags != 16384: return True return False; But this is extremely inefficient : the repo.status() takes forever -- at least compared to the git status command line. So my question is : is there a more efficient way to know if the