From c2404728b623588aa89920ae435b48af0fef011e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 22 Jun 2023 15:49:05 +0300 Subject: Add branch sub-option for git project vcs in bdep-new Also fix tests which failed if for the initial branch git-init defaults to the name other than 'master'. --- bdep/git.cxx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'bdep/git.cxx') diff --git a/bdep/git.cxx b/bdep/git.cxx index cc697b3..f9bdc04 100644 --- a/bdep/git.cxx +++ b/bdep/git.cxx @@ -24,10 +24,8 @@ namespace bdep static optional bun_git_ver; #endif - // Check that git is at least of the specified minimum supported version. - // - void - git_check_version (const semantic_version& min_ver, bool system) + bool + git_try_check_version (const semantic_version& min_ver, bool system) { // Query and cache git version on the first call. // @@ -50,9 +48,24 @@ namespace bdep // Note that we don't expect the min_ver to contain the build component, // that doesn't matter functionality-wise for git. // - if (*gv < min_ver) + return *gv >= min_ver; + } + + // As above but issue diagnostics and fail if git is older than the + // specified minimum supported version. + // + void + git_check_version (const semantic_version& min_ver, bool system) + { + if (!git_try_check_version (min_ver, system)) + { + optional& gv (system ? sys_git_ver : bun_git_ver); + + assert (gv); // Must have been cached by git_try_check_version(). + fail << "unsupported git version " << *gv << info << "minimum supported version is " << min_ver << endf; + } } // Return git process path and the --exec-path option, if it is required for -- cgit v1.1