@@ -72,11 +72,16 @@ def update(self):
72
72
73
73
def repo_exists (self ):
74
74
try :
75
- git . Repo ( self .working_dir )
75
+ self ._repo
76
76
except (InvalidGitRepositoryError , NoSuchPathError ):
77
77
return False
78
78
return True
79
79
80
+ @property
81
+ def _repo (self ):
82
+ """Get a `git.Repo` instance from the current `self.working_dir`."""
83
+ return git .Repo (self .working_dir , expand_vars = False )
84
+
80
85
def are_submodules_available (self , config ):
81
86
"""Test whether git submodule checkout step should be performed."""
82
87
submodules_in_config = (
@@ -232,7 +237,7 @@ def lsremote(self):
232
237
@property
233
238
def tags (self ):
234
239
versions = []
235
- repo = git . Repo ( self .working_dir )
240
+ repo = self ._repo
236
241
237
242
# Build a cache of tag -> commit
238
243
# GitPython is not very optimized for reading large numbers of tags
@@ -265,7 +270,7 @@ def tags(self):
265
270
266
271
@property
267
272
def branches (self ):
268
- repo = git . Repo ( self .working_dir )
273
+ repo = self ._repo
269
274
versions = []
270
275
branches = []
271
276
@@ -291,8 +296,7 @@ def commit(self):
291
296
292
297
@property
293
298
def submodules (self ):
294
- repo = git .Repo (self .working_dir )
295
- return list (repo .submodules )
299
+ return list (self ._repo .submodules )
296
300
297
301
def checkout (self , identifier = None ):
298
302
"""Checkout to identifier or latest."""
@@ -350,8 +354,7 @@ def find_ref(self, ref):
350
354
351
355
def ref_exists (self , ref ):
352
356
try :
353
- r = git .Repo (self .working_dir )
354
- if r .commit (ref ):
357
+ if self ._repo .commit (ref ):
355
358
return True
356
359
except (BadName , ValueError ):
357
360
return False
0 commit comments