From 84e7930fa800725080479a3935a12596c699512f Mon Sep 17 00:00:00 2001 From: Uwe Seimet Date: Fri, 8 Dec 2023 00:46:55 +0100 Subject: [PATCH] Update patch version handling --- cpp/s2pctl/s2pctl_display.cpp | 3 +++ cpp/test/s2pctl_display_test.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cpp/s2pctl/s2pctl_display.cpp b/cpp/s2pctl/s2pctl_display.cpp index 864c7963..97056376 100644 --- a/cpp/s2pctl/s2pctl_display.cpp +++ b/cpp/s2pctl/s2pctl_display.cpp @@ -106,6 +106,9 @@ string S2pCtlDisplay::DisplayVersionInfo(const PbVersionInfo& version_info) cons } else { version += fmt::format(" {0}.{1}", version_info.major_version(), version_info.minor_version()); + if (version_info.patch_version() > 0) { + version += fmt::format(".{}", version_info.patch_version()); + } } version += version_info.suffix() + "\n"; diff --git a/cpp/test/s2pctl_display_test.cpp b/cpp/test/s2pctl_display_test.cpp index 40270d6d..c7c19ce4 100644 --- a/cpp/test/s2pctl_display_test.cpp +++ b/cpp/test/s2pctl_display_test.cpp @@ -75,16 +75,20 @@ TEST(S2pCtlDisplayTest, DisplayVersionInfo) info.set_major_version(1); info.set_minor_version(2); info.set_patch_version(3); + info.set_identifier("identifier"); string s = display.DisplayVersionInfo(info); EXPECT_FALSE(s.empty()); - EXPECT_EQ(string::npos, s.find("development version")); EXPECT_NE(string::npos, s.find("1.2.3")); info.set_patch_version(-1); s = display.DisplayVersionInfo(info); EXPECT_FALSE(s.empty()); - EXPECT_NE(string::npos, s.find("development version")); EXPECT_NE(string::npos, s.find("1.2")); + + info.set_suffix("rc"); + s = display.DisplayVersionInfo(info); + EXPECT_FALSE(s.empty()); + EXPECT_NE(string::npos, s.find("rc")); } TEST(S2pCtlDisplayTest, DisplayLogLevelInfo)