1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
diff --git a/PyGitUp/gitup.py b/PyGitUp/gitup.py
index c1c3e1f..0b3c2d5 100644
--- a/PyGitUp/gitup.py
+++ b/PyGitUp/gitup.py
@@ -22,13 +22,8 @@ from urllib.error import HTTPError, URLError
from urllib.request import urlopen
# 3rd party libs
-try:
- # noinspection PyUnresolvedReferences
- import pkg_resources as pkg
-except ImportError: # pragma: no cover
- NO_DISTRIBUTE = True
-else: # pragma: no cover
- NO_DISTRIBUTE = False
+import importlib.metadata
+import importlib.resources
import colorama
from git import Repo, GitCmdObjectDB
@@ -88,7 +83,6 @@ class GitUp:
'rebase.arguments': None,
'rebase.auto': True,
'rebase.log-hook': None,
- 'updates.check': True,
'push.auto': False,
'push.tags': False,
'push.all': False,
@@ -414,40 +408,11 @@ class GitUp:
def version_info(self):
""" Tell, what version we're running at and if it's up to date. """
- # Retrive and show local version info
- package = pkg.get_distribution('git-up')
- local_version_str = package.version
- local_version = package.parsed_version
+ # Retrieve and show local version info
+ local_version_str = importlib.metadata.version('git-up')
print('GitUp version is: ' + colored('v' + local_version_str, 'green'))
- if not self.settings['updates.check']:
- return
-
- # Check for updates
- print('Checking for updates...', end='')
-
- try:
- # Get version information from the PyPI JSON API
- reader = codecs.getreader('utf-8')
- details = json.load(reader(urlopen(PYPI_URL)))
- online_version = details['info']['version']
- except (HTTPError, URLError, ValueError):
- recent = True # To not disturb the user with HTTP/parsing errors
- else:
- recent = local_version >= pkg.parse_version(online_version)
-
- if not recent:
- # noinspection PyUnboundLocalVariable
- print(
- '\rRecent version is: '
- + colored('v' + online_version, color='yellow', attrs=['bold'])
- )
- print('Run \'pip install -U git-up\' to get the update.')
- else:
- # Clear the update line
- sys.stdout.write('\r' + ' ' * 80 + '\n')
-
###########################################################################
# Helpers
###########################################################################
@@ -554,11 +519,7 @@ def run(): # pragma: no cover
args = parser.parse_args()
if args.version:
- if NO_DISTRIBUTE:
- print(colored('Please install \'git-up\' via pip in order to '
- 'get version information.', 'yellow'))
- else:
- GitUp(sparse=True).version_info()
+ GitUp(sparse=True).version_info()
return
if args.quiet:
|