diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-05-05 16:08:00 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-05-05 16:08:00 +0300 |
commit | 33aa05190dc3c3e0117abbcffc4525266edbcb1c (patch) | |
tree | d5e857f409e4409a9197ad6e2c0637f8243c17c1 | |
parent | aae351ab537a4c7b62511ef72a8b3822c7722b2c (diff) |
Make use of parse_standard_version() function
-rw-r--r-- | bpkg/fetch-git.cxx | 26 |
1 files changed, 8 insertions, 18 deletions
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<standard_version> 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; |