aboutsummaryrefslogtreecommitdiffstats
path: root/git_deps/gitutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'git_deps/gitutils.py')
-rw-r--r--git_deps/gitutils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/git_deps/gitutils.py b/git_deps/gitutils.py
index f349f44..f7b5470 100644
--- a/git_deps/gitutils.py
+++ b/git_deps/gitutils.py
@@ -3,6 +3,8 @@ import re
import subprocess
from git_deps.errors import InvalidCommitish
+from git_deps.utils import abort
+
class GitUtils(object):
@classmethod
@@ -89,3 +91,11 @@ class GitUtils(object):
return commit
+ @classmethod
+ def get_repo(cls, path='.'):
+ try:
+ repo_path = pygit2.discover_repository(path)
+ except KeyError:
+ abort("Couldn't find a repository in the current directory.")
+
+ return pygit2.Repository(repo_path)