Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0b6cde8

Browse files
committed
Fix GitError being raised in initial import git
This catches any raise of one of the custom exceptions defined in `git.exc` during the imports in the dunder init, and raises an `ImportError` in those cases.
1 parent cf8dc25 commit 0b6cde8

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

git/__init__.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,26 @@ def _init_externals():
3535

3636
#{ Imports
3737

38-
from git.config import GitConfigParser # @NoMove @IgnorePep8
39-
from git.objects import * # @NoMove @IgnorePep8
40-
from git.refs import * # @NoMove @IgnorePep8
41-
from git.diff import * # @NoMove @IgnorePep8
42-
from git.exc import * # @NoMove @IgnorePep8
43-
from git.db import * # @NoMove @IgnorePep8
44-
from git.cmd import Git # @NoMove @IgnorePep8
45-
from git.repo import Repo # @NoMove @IgnorePep8
46-
from git.remote import * # @NoMove @IgnorePep8
47-
from git.index import * # @NoMove @IgnorePep8
48-
from git.util import ( # @NoMove @IgnorePep8
49-
LockFile,
50-
BlockingLockFile,
51-
Stats,
52-
Actor,
53-
rmtree,
54-
)
38+
from git.exc import * # @NoMove @IgnorePep8
39+
try:
40+
from git.config import GitConfigParser # @NoMove @IgnorePep8
41+
from git.objects import * # @NoMove @IgnorePep8
42+
from git.refs import * # @NoMove @IgnorePep8
43+
from git.diff import * # @NoMove @IgnorePep8
44+
from git.db import * # @NoMove @IgnorePep8
45+
from git.cmd import Git # @NoMove @IgnorePep8
46+
from git.repo import Repo # @NoMove @IgnorePep8
47+
from git.remote import * # @NoMove @IgnorePep8
48+
from git.index import * # @NoMove @IgnorePep8
49+
from git.util import ( # @NoMove @IgnorePep8
50+
LockFile,
51+
BlockingLockFile,
52+
Stats,
53+
Actor,
54+
rmtree,
55+
)
56+
except GitError as exc:
57+
raise ImportError('%s: %s' % (exc.__class__.__name__, exc))
5558

5659
#} END imports
5760

0 commit comments

Comments
 (0)