From b0b19063bffe83af805f2b92106b7da47e21a5d4 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 14 Aug 2018 19:08:10 +0300 Subject: Make git_version() to return semantic_version rather than standard_version --- libbutl/git.cxx | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'libbutl/git.cxx') diff --git a/libbutl/git.cxx b/libbutl/git.cxx index bb5f542..28a790f 100644 --- a/libbutl/git.cxx +++ b/libbutl/git.cxx @@ -28,7 +28,7 @@ import std.core; #endif import butl.path; import butl.optional; -import butl.standard_version +import butl.semantic_version #endif import butl.utility; // digit() @@ -37,7 +37,7 @@ import butl.filesystem; // entry_exists() #include #include #include -#include +#include #endif using namespace std; @@ -55,7 +55,7 @@ namespace butl true /* ignore_errors */); } - optional + optional git_version (const string& s) { // There is some variety across platforms in the version @@ -65,24 +65,8 @@ namespace butl // MacOS: git version 2.10.1 (Apple Git-78) // MinGit: git version 2.16.1.windows.1 // - // We will consider the first 3 version components that follows the - // common 'git version ' prefix. - // - const size_t b (12); - if (s.compare (0, b, "git version ") == 0) - { - size_t i (b); - size_t n (0); - for (char c; i != s.size () && (digit (c = s[i]) || c == '.'); ++i) - { - if (c == '.' && ++n == 3) - break; - } - - // Returns nullopt if fail to parse. - // - return parse_standard_version (string (s, b, i - b)); - } + if (s.compare (0, 12, "git version ") == 0) + return parse_semantic_version (s, 12, "" /* build_separators */); return nullopt; } -- cgit v1.1