diff options
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r-- | lib/git/repo.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py index aff595f1..fdfb7928 100644 --- a/lib/git/repo.py +++ b/lib/git/repo.py @@ -435,5 +435,36 @@ class Repo(object): alternates = property(_get_alternates, _set_alternates) + @property + def is_dirty(self): + """ + Return the status of the working directory. + + Returns + ``True``, if the working directory has any uncommitted changes, + otherwise ``False`` + + """ + if self.bare: + # Bare repositories with no associated working directory are + # always consired to be clean. + return False + + return len(self.git.diff('HEAD').strip()) > 0 + + @property + def active_branch(self): + """ + The name of the currently active branch. + + Returns + str (the branch name) + """ + branch = self.git.symbolic_ref('HEAD').strip() + if branch.startswith('refs/heads/'): + branch = branch[len('refs/heads/'):] + + return branch + def __repr__(self): return '<GitPython.Repo "%s">' % self.path |