Skip to content

Commit 42bb085

Browse files
authored
Make mypy -V show git commit hash more often (#2394)
1 parent c954fa3 commit 42bb085

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

mypy/version.py

+10
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
import os
2+
from mypy import git
3+
14
__version__ = '0.4.6-dev'
5+
6+
mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
7+
if git.is_git_repo(mypy_dir) and git.have_git():
8+
__version__ += '-' + git.git_revision(mypy_dir).decode('utf-8')
9+
if git.is_dirty(mypy_dir):
10+
__version__ += '-dirty'
11+
del mypy_dir

setup.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,6 @@
3131
'''.lstrip()
3232

3333

34-
def cache_version_id():
35-
"""Returns the version id to use for the incremental hash.
36-
37-
If setup.py is run from a git repo, the git commit hash will be
38-
included if possible. If not, then this function will fall back to
39-
using the default version id from mypy/version.py."""
40-
if git.is_git_repo('.') and git.have_git():
41-
return __version__ + '-' + git.git_revision('.').decode('utf-8')
42-
else:
43-
# Default fallback
44-
return __version__
45-
46-
4734
def find_data_files(base, globs):
4835
"""Find all interesting data files, for setup(data_files=)
4936
@@ -71,7 +58,7 @@ def pin_version(self):
7158
path = os.path.join(self.build_lib, 'mypy')
7259
self.mkpath(path)
7360
with open(os.path.join(path, 'version.py'), 'w') as stream:
74-
stream.write('__version__ = "{}"\n'.format(cache_version_id()))
61+
stream.write('__version__ = "{}"\n'.format(version))
7562

7663
def run(self):
7764
self.execute(self.pin_version, ())

0 commit comments

Comments
 (0)