aboutsummaryrefslogtreecommitdiff
path: root/bdep/git.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-08-06 22:15:05 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-08-07 15:14:44 +0300
commit4f2d4022dca65da2a6f03e1f27df13deeaab360a (patch)
tree7fe826041792c7e51792283f28ee29c1744e04f9 /bdep/git.cxx
parent228a2dfec33eb9ba966894bd23c2f4db51a7e330 (diff)
Add git version check (2.12 is minimum supported)
Diffstat (limited to 'bdep/git.cxx')
-rw-r--r--bdep/git.cxx30
1 files changed, 22 insertions, 8 deletions
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 <bdep/git.hxx>
-#include <libbutl/filesystem.mxx>
+#include <libbutl/git.mxx>
+#include <libbutl/standard-version.mxx>
#include <bdep/diagnostics.hxx>
@@ -12,14 +13,27 @@ using namespace butl;
namespace bdep
{
- bool
- git (const dir_path& d)
+ static optional<standard_version> 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<string> 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<string>