1 # Copyright (c) David Aguilar
2 """Provide git-cola's version number"""
3 from __future__
import division
, absolute_import
, unicode_literals
8 if __name__
== '__main__':
9 srcdir
= os
.path
.dirname(os
.path
.dirname(__file__
))
10 sys
.path
.insert(1, srcdir
)
12 from cola
.git
import git
13 from cola
.git
import STDOUT
14 from cola
.decorators
import memoize
15 from cola
._version
import VERSION
17 # minimum version requirements
19 # git-diff learned --patience in 1.6.2
20 # git-mergetool learned --no-prompt in 1.6.2
21 # git-difftool moved out of contrib in git 1.6.3
25 'pyqt_qrunnable': '4.4',
26 'diff-submodule': '1.6.6',
31 """Returns an entry from the known versions table"""
32 return _versions
.get(key
)
36 """Returns the current version"""
41 def check_version(min_ver
, ver
):
42 """Check whether ver is greater or equal to min_ver
44 min_ver_list
= version_to_list(min_ver
)
45 ver_list
= version_to_list(ver
)
46 return min_ver_list
<= ver_list
51 """Checks if a version is greater than the known version for <what>"""
52 return check_version(get(key
), ver
)
55 def version_to_list(version
):
56 """Convert a version string to a list of numbers or strings
59 for p
in version
.split('.'):
69 def git_version_str():
70 """Returns the current GIT version"""
71 return git
.version()[STDOUT
].strip()
75 """Returns the current GIT version"""
76 parts
= git_version_str().split()
77 if parts
and len(parts
) >= 3:
80 # minimum supported version
84 def print_version(brief
=False):
86 print('%s' % version())
88 print('cola version %s' % version())
91 if __name__
== '__main__':