Skip to content

Commit

Permalink
better error if pygit2 is missing [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs committed Oct 24, 2019
1 parent 1bc93a8 commit 80e2e5b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dev/tasks/crossbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@
try:
import pygit2
except ImportError:
PygitRepository = str
PygitRemoteCallbacks = object
else:
PygitRepository = pygit2.Repository
PygitRemoteCallbacks = pygit2.RemoteCallbacks


Expand Down Expand Up @@ -260,10 +258,10 @@ class Repo:
def __init__(self, path, github_token=None, remote_url=None,
require_https=False):
self.path = Path(path)
self.repo = PygitRepository(str(self.path))
self.github_token = github_token
self.require_https = require_https
self._remote_url = remote_url
self._pygit_repo = None
self._github_repo = None # set by as_github_repo()
self._updated_refs = []

Expand All @@ -278,6 +276,12 @@ def __str__(self):
head=self.head
)

@property
def repo(self):
if self._pygit_repo is None:
self._pygit_repo = pygit2.Repository(str(self.path))
return self._pygit_repo

@property
def origin(self):
remote = self.repo.remotes['origin']
Expand Down

0 comments on commit 80e2e5b

Please sign in to comment.