From cd315fecaf4c7473950c1610e06417634b416954 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 16 Aug 2021 18:54:15 +0300 Subject: Optimize rep-fetch for dir and git repos quering projects info in single call --- bpkg/manifest-utility.hxx | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'bpkg/manifest-utility.hxx') diff --git a/bpkg/manifest-utility.hxx b/bpkg/manifest-utility.hxx index 29d548d..b7d9b07 100644 --- a/bpkg/manifest-utility.hxx +++ b/bpkg/manifest-utility.hxx @@ -95,20 +95,29 @@ namespace bpkg bool repository_name (const string&); - // Return the version of a package as provided by the build2 version module. - // Return nullopt if the version module is disabled for the package (or the - // build2 project directory doesn't contain the manifest file). Fail if the - // directory is not a build2 project. + // Return the versions of packages as provided by the build2 version module. + // Return nullopt for a package if the version module is disabled for it (or + // the build2 project directory doesn't contain the manifest file). Fail if + // any of the specified directories is not a build2 project. // - // Note that if the package directory is under the version control, then the + // Note that if a package directory is under the version control, then the // resulting version may be populated with the snapshot information (see // libbutl/standard-version.mxx for more details). Thus, this function can - // be used for fixing up the package manifest version. + // be used for fixing up the package manifest versions. // class common_options; - optional - package_version (const common_options&, const dir_path&); + vector> + package_versions (const common_options&, const dir_paths&); + + // As above but return the version of a single package. + // + inline optional + package_version (const common_options& o, const dir_path& d) + { + vector> r (package_versions (o, dir_paths ({d}))); + return move (r[0]); + } } #endif // BPKG_MANIFEST_UTILITY_HXX -- cgit v1.1