Skip to content

Commit 609a294

Browse files
committed
set git refresh before importing errors/repo
1 parent d2a14bf commit 609a294

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

floatcsep/accessors.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from urllib.parse import urlencode
44
from csep.utils.time_utils import datetime_to_utc_epoch, utc_now_datetime
55
from csep.core.catalogs import CSEPCatalog
6-
from git import Repo, InvalidGitRepositoryError, NoSuchPathError
6+
import git
77
import requests
88
import hashlib
99
import os
@@ -97,10 +97,12 @@ def from_git(url, path, branch=None, depth=1, **kwargs):
9797
"""
9898

9999
kwargs.update({'depth': depth})
100+
git.refresh()
101+
100102
try:
101-
repo = Repo(path)
102-
except (NoSuchPathError, InvalidGitRepositoryError):
103-
repo = Repo.clone_from(url, path, branch=branch, **kwargs)
103+
repo = git.Repo(path)
104+
except (git.NoSuchPathError, git.InvalidGitRepositoryError):
105+
repo = git.Repo.clone_from(url, path, branch=branch, **kwargs)
104106
git_dir = os.path.join(path, '.git')
105107
if os.path.isdir(git_dir):
106108
shutil.rmtree(git_dir)

tests/unit/test_accessors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def tearDownClass(cls) -> None:
9696

9797

9898
class TestGitter(unittest.TestCase):
99-
@mock.patch('floatcsep.accessors.Repo')
99+
@mock.patch('floatcsep.accessors.git.Repo')
100100
@mock.patch('git.Git')
101101
def runTest(self, mock_git, mock_repo):
102102
p = mock.PropertyMock(return_value=False)

0 commit comments

Comments
 (0)