Welcome: handle local dev versions (with +, not -) correctly

The Welcome class prints a message if the server recommends a CLI version
that's newer than what the client is currently using, but only if the client
is running a "release" version, not a "local" development one. "local"
versions have a "+" in them (at least when Versioneer creates it), but
Welcome was looking for "-" as an indicator. So it was printing the warning
when it shouldn't be.
This commit is contained in:
Brian Warner 2017-04-06 19:32:05 -07:00
parent 1a7b3baaf2
commit 6aa7fe7c82
2 changed files with 3 additions and 3 deletions

View File

@ -10,9 +10,9 @@ class CLIWelcomeHandler(_WelcomeHandler):
def handle_welcome(self, welcome): def handle_welcome(self, welcome):
# Only warn if we're running a release version (e.g. 0.0.6, not # Only warn if we're running a release version (e.g. 0.0.6, not
# 0.0.6-DISTANCE-gHASH). Only warn once. # 0.0.6+DISTANCE.gHASH). Only warn once.
if ("current_cli_version" in welcome if ("current_cli_version" in welcome
and "-" not in self._current_version and "+" not in self._current_version
and not self._version_warning_displayed and not self._version_warning_displayed
and welcome["current_cli_version"] != self._current_version): and welcome["current_cli_version"] != self._current_version):
print("Warning: errors may occur unless both sides are running the same version", file=self.stderr) print("Warning: errors may occur unless both sides are running the same version", file=self.stderr)

View File

@ -932,7 +932,7 @@ class Welcome(unittest.TestCase):
def test_version_unreleased(self): def test_version_unreleased(self):
stderr = self.do({"current_cli_version": "3.0"}, stderr = self.do({"current_cli_version": "3.0"},
my_version="2.5-middle-something") my_version="2.5+middle.something")
self.assertEqual(stderr, "") self.assertEqual(stderr, "")
def test_motd(self): def test_motd(self):