File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,13 @@ class PathIsDirectoryError(ValueError): pass
5858GL_STATUS_IGNORED = 3
5959
6060
61+ def error_on_none (path ):
62+ """Raise a KeyError if the ```path``` argument is None."""
63+ if path is None :
64+ raise KeyError ('path' )
65+ return path
66+
67+
6168def init_repository (url = None ):
6269 """Creates a new Gitless's repository in the cwd.
6370
@@ -67,7 +74,7 @@ def init_repository(url=None):
6774 """
6875 cwd = os .getcwd ()
6976 try :
70- pygit2 .discover_repository (cwd )
77+ error_on_none ( pygit2 .discover_repository (cwd ) )
7178 raise GlError ('You are already in a Gitless repository' )
7279 except KeyError : # Expected
7380 if not url :
@@ -108,7 +115,7 @@ class Repository(object):
108115 def __init__ (self ):
109116 """Create a Repository out of the current working repository."""
110117 try :
111- path = pygit2 .discover_repository (os .getcwd ())
118+ path = error_on_none ( pygit2 .discover_repository (os .getcwd () ))
112119 except KeyError :
113120 raise NotInRepoError ('You are not in a Gitless\' s repository' )
114121
You can’t perform that action at this time.
0 commit comments