diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-08-06 22:15:05 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-08-07 15:14:44 +0300 |
commit | 4f2d4022dca65da2a6f03e1f27df13deeaab360a (patch) | |
tree | 7fe826041792c7e51792283f28ee29c1744e04f9 /bdep/git.txx | |
parent | 228a2dfec33eb9ba966894bd23c2f4db51a7e330 (diff) |
Add git version check (2.12 is minimum supported)
Diffstat (limited to 'bdep/git.txx')
-rw-r--r-- | bdep/git.txx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/bdep/git.txx b/bdep/git.txx new file mode 100644 index 0000000..aef5f3d --- /dev/null +++ b/bdep/git.txx @@ -0,0 +1,50 @@ +// file : bdep/git.txx -*- C++ -*- +// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +namespace bdep +{ + template <typename... A> + void + run_git (const dir_path& repo, A&&... args) + { + process pr (start_git (repo, + 0 /* stdin */, + 1 /* stdout */, + 2 /* stderr */, + forward<A> (args)...)); + + finish_git (pr); + } + + void + git_check_version (); + + template <typename I, typename O, typename E, typename... A> + process + start_git (I&& in, O&& out, E&& err, A&&... args) + { + git_check_version (); + + return start (forward<I> (in), + forward<O> (out), + forward<E> (err), + "git", + forward<A> (args)...); + } + + template <typename... A> + optional<string> + git_line (bool ie, A&&... args) + { + fdpipe pipe (fdopen_pipe ()); + auto_fd null (ie ? fdnull () : auto_fd ()); + + process pr (start_git (0 /* stdin */, + pipe /* stdout */, + ie ? null.get () : 2 /* stderr */, + forward<A> (args)...)); + + return git_line (move (pr), move (pipe), ie); + } +} |