From 4f2d4022dca65da2a6f03e1f27df13deeaab360a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 6 Aug 2018 22:15:05 +0300 Subject: Add git version check (2.12 is minimum supported) --- bdep/git.cxx | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'bdep/git.cxx') diff --git a/bdep/git.cxx b/bdep/git.cxx index c26d257..c0b48fc 100644 --- a/bdep/git.cxx +++ b/bdep/git.cxx @@ -4,7 +4,8 @@ #include -#include +#include +#include #include @@ -12,14 +13,27 @@ using namespace butl; namespace bdep { - bool - git (const dir_path& d) + static optional git_ver; + + void + git_check_version () { - // .git can be either a directory or a file in case of a submodule. - // - return entry_exists (d / ".git", - true /* follow_symlinks */, - true /* ignore_errors */); + if (!git_ver) + { + // Make sure that the getline() function call doesn't end up with an + // infinite recursion. + // + git_ver = standard_version (); + + optional s (git_line (false /* ignore_error */, "--version")); + + if (!s || !(git_ver = git_version (*s))) + fail << "unable to obtain git version"; + + if (git_ver->version < 20120000000) + fail << "unsupported git version " << *git_ver << + info << "minimum supported version is 2.12.0" << endf; + } } optional -- cgit v1.1