From 8e5f53fd249f08b0be0a7d4eec65f425cfb79eae Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 14 Aug 2018 19:28:54 +0300 Subject: Adapt to git_version() returning semantic_version now --- bdep/git.cxx | 24 ++++++++++++++---------- bdep/git.hxx | 10 +++++----- bdep/git.ixx | 4 ++-- bdep/git.txx | 8 ++++---- bdep/project-email.cxx | 4 +--- bdep/publish.cxx | 3 ++- bdep/types.hxx | 6 +++--- 7 files changed, 31 insertions(+), 28 deletions(-) (limited to 'bdep') diff --git a/bdep/git.cxx b/bdep/git.cxx index 79e6255..a5e2be4 100644 --- a/bdep/git.cxx +++ b/bdep/git.cxx @@ -12,32 +12,36 @@ using namespace butl; namespace bdep { - static optional git_ver; + static optional git_ver; - // On the first call check that git is at least of the specified minimum - // supported version. + // Check that git is at least of the specified minimum supported version. // void - git_check_version (const standard_version& min_ver) + git_check_version (const semantic_version& min_ver) { + // Query and cache git version on the first call. + // if (!git_ver) { // Make sure that the getline() function call doesn't end up with an // infinite recursion. // - git_ver = standard_version (); + git_ver = semantic_version (); - optional s (git_line (min_ver, + optional s (git_line (*git_ver, false /* ignore_error */, "--version")); if (!s || !(git_ver = git_version (*s))) fail << "unable to obtain git version"; - - if (*git_ver < min_ver) - fail << "unsupported git version " << *git_ver << - info << "minimum supported version is " << min_ver << endf; } + + // Note that we don't expect the min_ver to contain the build component, + // that doesn't matter functionality-wise for git. + // + if (*git_ver < min_ver) + fail << "unsupported git version " << *git_ver << + info << "minimum supported version is " << min_ver << endf; } optional diff --git a/bdep/git.hxx b/bdep/git.hxx index 6b112c8..fcc9513 100644 --- a/bdep/git.hxx +++ b/bdep/git.hxx @@ -21,11 +21,11 @@ namespace bdep // template process - start_git (const standard_version&, I&& in, O&& out, E&& err, A&&... args); + start_git (const semantic_version&, I&& in, O&& out, E&& err, A&&... args); template process - start_git (const standard_version&, + start_git (const semantic_version&, const dir_path& repo, I&& in, O&& out, E&& err, A&&... args); @@ -39,18 +39,18 @@ namespace bdep // template void - run_git (const standard_version&, const dir_path& repo, A&&... args); + run_git (const semantic_version&, const dir_path& repo, A&&... args); // Return the first line of the git output. If ignore_error is true, then // suppress stderr, ignore (normal) error exit status, and return nullopt. // template optional - git_line (const standard_version&, bool ignore_error, A&&... args); + git_line (const semantic_version&, bool ignore_error, A&&... args); template optional - git_line (const standard_version&, + git_line (const semantic_version&, const dir_path& repo, bool ignore_error, A&&... args); diff --git a/bdep/git.ixx b/bdep/git.ixx index 0e3ee9f..379f392 100644 --- a/bdep/git.ixx +++ b/bdep/git.ixx @@ -6,7 +6,7 @@ namespace bdep { template inline process - start_git (const standard_version& min_ver, + start_git (const semantic_version& min_ver, const dir_path& repo, I&& in, O&& out, E&& err, A&&... args) @@ -25,7 +25,7 @@ namespace bdep template inline optional - git_line (const standard_version& min_ver, + git_line (const semantic_version& min_ver, const dir_path& repo, bool ie, A&&... args) diff --git a/bdep/git.txx b/bdep/git.txx index 19a9d42..4abae3c 100644 --- a/bdep/git.txx +++ b/bdep/git.txx @@ -6,7 +6,7 @@ namespace bdep { template void - run_git (const standard_version& min_ver, const dir_path& repo, A&&... args) + run_git (const semantic_version& min_ver, const dir_path& repo, A&&... args) { process pr (start_git (min_ver, repo, @@ -17,11 +17,11 @@ namespace bdep } void - git_check_version (const standard_version& min_ver); + git_check_version (const semantic_version& min_ver); template process - start_git (const standard_version& min_ver, + start_git (const semantic_version& min_ver, I&& in, O&& out, E&& err, A&&... args) { @@ -34,7 +34,7 @@ namespace bdep template optional - git_line (const standard_version& min_ver, bool ie, A&&... args) + git_line (const semantic_version& min_ver, bool ie, A&&... args) { fdpipe pipe (fdopen_pipe ()); auto_fd null (ie ? fdnull () : auto_fd ()); diff --git a/bdep/project-email.cxx b/bdep/project-email.cxx index 9e8bbc9..fe43b18 100644 --- a/bdep/project-email.cxx +++ b/bdep/project-email.cxx @@ -11,8 +11,6 @@ using namespace butl; namespace bdep { - static const standard_version git_ver ("2.1.0"); - optional project_email (const dir_path& prj) { @@ -37,7 +35,7 @@ namespace bdep // resolved value can be queried with the GIT_AUTHOR_IDENT logical // variable. // - if (optional l = git_line (git_ver, + if (optional l = git_line (semantic_version {2, 1, 0}, prj, true /* ignore_error */, "var", "GIT_AUTHOR_IDENT")) diff --git a/bdep/publish.cxx b/bdep/publish.cxx index 1afdd36..c498361 100644 --- a/bdep/publish.cxx +++ b/bdep/publish.cxx @@ -8,6 +8,7 @@ #include // fdterm() #include +#include #include #include @@ -29,7 +30,7 @@ namespace bdep // worktree command used. We also use bpkg that caps the git version at // 2.12, so let's use is as the lowest common denominator. // - static const standard_version git_ver ("2.12.0"); + static const semantic_version git_ver {2, 12, 0}; static inline url parse_url (const string& s, const char* what) diff --git a/bdep/types.hxx b/bdep/types.hxx index 0c13639..7cf5c41 100644 --- a/bdep/types.hxx +++ b/bdep/types.hxx @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace bdep { @@ -111,9 +111,9 @@ namespace bdep using butl::fdopen_mode; using butl::fdstream_mode; - // + // // - using butl::standard_version; + using butl::semantic_version; } // In order to be found (via ADL) these have to be either in std:: or in -- cgit v1.1