summaryrefslogtreecommitdiff
path: root/lib/git/repo.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r--lib/git/repo.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py
index aaa7cecc..55f73f66 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -458,5 +458,19 @@ class Repo(object):
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