Skip to content

Commit 5096e70

Browse files
committed
improve support for master version
1 parent 52fb426 commit 5096e70

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

libtmux/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ def _is_executable_file_or_link(exe):
405405
def get_version():
406406
"""Return tmux version.
407407
408+
If tmux is built from git master, the version returned will be the latest
409+
version appended with -master, e.g. ``2.4-master``.
410+
408411
:returns: tmux version
409412
:rtype: :class:`distutils.version.LooseVersion`
410413
"""
@@ -423,7 +426,7 @@ def get_version():
423426

424427
# Allow latest tmux HEAD
425428
if version == 'master':
426-
return LooseVersion(TMUX_MAX_VERSION)
429+
return LooseVersion('%s-master' % TMUX_MAX_VERSION)
427430

428431
version = re.sub(r'[a-z]', '', version)
429432

tests/test_common.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from libtmux.common import (
1414
has_minimum_version, which, session_check_name, tmux_cmd,
1515
has_version, has_gt_version, has_lt_version, get_version,
16-
has_gte_version, has_lte_version, TMUX_MAX_VERSION
16+
has_gte_version, has_lte_version, TMUX_MAX_VERSION, TMUX_MIN_VERSION
1717
)
1818
from libtmux.exc import LibTmuxException, BadSessionName, TmuxCommandNotFound
1919

@@ -29,6 +29,13 @@ class Hi(object):
2929
monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)
3030

3131
assert has_minimum_version()
32+
assert has_gte_version(TMUX_MIN_VERSION)
33+
assert has_gt_version(TMUX_MAX_VERSION), (
34+
"Greater than the max-supported version"
35+
)
36+
assert '%s-master' % TMUX_MAX_VERSION == get_version(), (
37+
"Is the latest supported version with -master appended"
38+
)
3239

3340

3441
def test_get_version_openbsd(monkeypatch):

0 commit comments

Comments
 (0)