From f2f08e0758243a820fe47128ffabaa474c0e86e7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 13 Apr 2018 23:38:12 +0300 Subject: Implement git repository handling transition (phase 0) --- bpkg/pkg-checkout.cxx | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'bpkg/pkg-checkout.cxx') diff --git a/bpkg/pkg-checkout.cxx b/bpkg/pkg-checkout.cxx index 6524730..1759991 100644 --- a/bpkg/pkg-checkout.cxx +++ b/bpkg/pkg-checkout.cxx @@ -6,6 +6,7 @@ #include +#include // git_checkout*() #include #include #include @@ -22,6 +23,38 @@ using namespace butl; namespace bpkg { + static void + checkout (const common_options& o, + const repository_location& rl, + const dir_path& dir, + const string& fragment, + const shared_ptr& ap) + { + switch (rl.type ()) + { + case repository_type::git: + { + git_checkout (o, dir, fragment); + + if (exists (dir / path (".gitmodules"))) + { + // Print the progress indicator to attribute the possible fetching + // progress. + // + if (verb) + text << "checking out " + << package_string (ap->id.name, ap->version); + + git_checkout_submodules (o, dir); + } + + break; + } + case repository_type::pkg: + case repository_type::dir: assert (false); break; + } + } + shared_ptr pkg_checkout (const common_options& o, const dir_path& c, @@ -106,10 +139,10 @@ namespace bpkg // working tree so all we need to do is distribute it to the package // directory. // - dir_path sd (c / repos_dir); + dir_path sd (c / repos_dir / repository_state (rl)); + + checkout (o, rl, sd, pl->fragment, ap); - sd /= repository_state (rl); - sd /= dir_path (pl->fragment); sd /= path_cast (pl->location); // Verify the package prerequisites are all configured since the dist -- cgit v1.1