From 33aa05190dc3c3e0117abbcffc4525266edbcb1c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 5 May 2018 16:08:00 +0300 Subject: Make use of parse_standard_version() function --- bpkg/fetch-git.cxx | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'bpkg/fetch-git.cxx') diff --git a/bpkg/fetch-git.cxx b/bpkg/fetch-git.cxx index fd19a3a..f36d057 100644 --- a/bpkg/fetch-git.cxx +++ b/bpkg/fetch-git.cxx @@ -109,7 +109,7 @@ namespace bpkg co.git_option (), "--version")); - standard_version v; + optional v; // There is some variety across platforms in the version // representation. @@ -132,20 +132,16 @@ namespace bpkg break; } - try - { - v = standard_version (string (s, b, i - b)); - } - catch (const invalid_argument&) {} + v = parse_standard_version (string (s, b, i - b)); } - if (v.empty ()) + if (!v) fail << "'" << s << "' doesn't appear to contain a git version" << info << "produced by '" << co.git () << "'; " << "use --git to override" << endg; - if (v.version < 20120000000) - fail << "unsupported git version " << v.string () << + if (v->version < 20120000000) + fail << "unsupported git version " << *v << info << "minimum supported version is 2.12.0" << endf; // Sanitize the environment. @@ -911,15 +907,9 @@ namespace bpkg refs::search_result r; for (const ref& rf: load_refs (co, url ())) { - if (!rf.peeled && rf.name.compare (0, 11, "refs/tags/v") == 0) - { - try - { - standard_version (string (rf.name, 11)); - r.push_back (rf); - } - catch (const invalid_argument&) {} - } + if (!rf.peeled && rf.name.compare (0, 11, "refs/tags/v") == 0 && + parse_standard_version (string (rf.name, 11))) + r.push_back (rf); } return r; -- cgit v1.1