diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-08-14 19:08:10 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-08-14 19:08:10 +0300 |
commit | b0b19063bffe83af805f2b92106b7da47e21a5d4 (patch) | |
tree | dd2754e633b5de45e134b1911c2e380410f171c7 | |
parent | 8561af5a2551ec453c9888125de273f2cc2940c0 (diff) |
Make git_version() to return semantic_version rather than standard_version
-rw-r--r-- | libbutl/git.cxx | 26 | ||||
-rw-r--r-- | libbutl/git.mxx | 6 | ||||
-rw-r--r-- | tests/semantic-version/driver.cxx | 2 |
3 files changed, 9 insertions, 25 deletions
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 <libbutl/utility.mxx> #include <libbutl/optional.mxx> #include <libbutl/filesystem.mxx> -#include <libbutl/standard-version.mxx> +#include <libbutl/semantic-version.mxx> #endif using namespace std; @@ -55,7 +55,7 @@ namespace butl true /* ignore_errors */); } - optional<standard_version> + optional<semantic_version> 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; } diff --git a/libbutl/git.mxx b/libbutl/git.mxx index b2023a6..56e5dee 100644 --- a/libbutl/git.mxx +++ b/libbutl/git.mxx @@ -21,11 +21,11 @@ import std.core; #endif import butl.path; import butl.optional; -import butl.standard_version +import butl.semantic_version #else #include <libbutl/path.mxx> #include <libbutl/optional.mxx> -#include <libbutl/standard-version.mxx> +#include <libbutl/semantic-version.mxx> #endif #include <libbutl/export.hxx> @@ -41,6 +41,6 @@ LIBBUTL_MODEXPORT namespace butl // Try to parse the line printed by the 'git --version' command. Return git // version if succeed, nullopt otherwise. // - LIBBUTL_SYMEXPORT optional<standard_version> + LIBBUTL_SYMEXPORT optional<semantic_version> git_version (const std::string&); } diff --git a/tests/semantic-version/driver.cxx b/tests/semantic-version/driver.cxx index 024e7a0..024aed0 100644 --- a/tests/semantic-version/driver.cxx +++ b/tests/semantic-version/driver.cxx @@ -27,7 +27,7 @@ int main () { using semver = semantic_version; - using failed = invalid_argument; + using failed = const invalid_argument&; // Construction. // |