Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/git/__init__.py: 78%

42 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1# __init__.py 

2# Copyright (C) 2008, 2009 Michael Trier (mtrier@gmail.com) and contributors 

3# 

4# This module is part of GitPython and is released under 

5# the BSD License: http://www.opensource.org/licenses/bsd-license.php 

6# flake8: noqa 

7# @PydevCodeAnalysisIgnore 

8from git.exc import * # @NoMove @IgnorePep8 

9import inspect 

10import os 

11import sys 

12import os.path as osp 

13 

14from typing import Optional 

15from git.types import PathLike 

16 

17__version__ = '3.1.29' 

18 

19 

20# { Initialization 

21def _init_externals() -> None: 

22 """Initialize external projects by putting them into the path""" 

23 if __version__ == '3.1.29' and "PYOXIDIZER" not in os.environ: 23 ↛ 26line 23 didn't jump to line 26, because the condition on line 23 was never false

24 sys.path.insert(1, osp.join(osp.dirname(__file__), "ext", "gitdb")) 

25 

26 try: 

27 import gitdb 

28 except ImportError as e: 

29 raise ImportError("'gitdb' could not be found in your PYTHONPATH") from e 

30 # END verify import 

31 

32 

33# } END initialization 

34 

35 

36################# 

37_init_externals() 

38################# 

39 

40# { Imports 

41 

42try: 

43 from git.config import GitConfigParser # @NoMove @IgnorePep8 

44 from git.objects import * # @NoMove @IgnorePep8 

45 from git.refs import * # @NoMove @IgnorePep8 

46 from git.diff import * # @NoMove @IgnorePep8 

47 from git.db import * # @NoMove @IgnorePep8 

48 from git.cmd import Git # @NoMove @IgnorePep8 

49 from git.repo import Repo # @NoMove @IgnorePep8 

50 from git.remote import * # @NoMove @IgnorePep8 

51 from git.index import * # @NoMove @IgnorePep8 

52 from git.util import ( # @NoMove @IgnorePep8 

53 LockFile, 

54 BlockingLockFile, 

55 Stats, 

56 Actor, 

57 rmtree, 

58 ) 

59except GitError as exc: 

60 raise ImportError("%s: %s" % (exc.__class__.__name__, exc)) from exc 

61 

62# } END imports 

63 

64__all__ = [name for name, obj in locals().items() if not (name.startswith("_") or inspect.ismodule(obj))] 

65 

66 

67# { Initialize git executable path 

68GIT_OK = None 

69 

70 

71def refresh(path: Optional[PathLike] = None) -> None: 

72 """Convenience method for setting the git executable path.""" 

73 global GIT_OK 

74 GIT_OK = False 

75 

76 if not Git.refresh(path=path): 76 ↛ 77line 76 didn't jump to line 77, because the condition on line 76 was never true

77 return 

78 if not FetchInfo.refresh(): 78 ↛ 79line 78 didn't jump to line 79, because the condition on line 78 was never true

79 return 

80 

81 GIT_OK = True 

82 

83 

84# } END initialize git executable path 

85 

86 

87################# 

88try: 

89 refresh() 

90except Exception as exc: 

91 raise ImportError("Failed to initialize: {0}".format(exc)) from exc 

92#################