diff options
-rw-r--r-- | bdep/init.cxx | 14 | ||||
-rw-r--r-- | bdep/sync.cxx | 27 | ||||
-rw-r--r-- | bdep/sync.hxx | 13 | ||||
-rw-r--r-- | tests/init.testscript | 4 |
4 files changed, 38 insertions, 20 deletions
diff --git a/bdep/init.cxx b/bdep/init.cxx index 16fc717..435c3cc 100644 --- a/bdep/init.cxx +++ b/bdep/init.cxx @@ -223,6 +223,8 @@ namespace bdep // db.reload (*c); + bool first (c->packages.empty ()); // First init for this project. + for (const package_location& p: pkgs) { if (initialized (p, c)) @@ -260,15 +262,19 @@ namespace bdep // Note: semantically equivalent to the first form of the sync // command. // + // If this is the first initialization of this project, also force + // full repository refetch for good measure (see GH issue #343 for + // details). + // if (sync) cmd_sync (o, prj, c, - false /* implicit */, + false /* implicit */, pkg_args, - true /* fetch */, - true /* yes */, - false /* name_cfg */, + first ? true : false /* fetch (full/shallow) */, + true /* yes */, + false /* name_cfg */, pkgs, so, create_host_config, diff --git a/bdep/sync.cxx b/bdep/sync.cxx index eac8b8c..77135fd 100644 --- a/bdep/sync.cxx +++ b/bdep/sync.cxx @@ -841,7 +841,7 @@ namespace bdep linked_configs&& linked_cfgs, const strings& pkg_args, bool implicit, - bool fetch, + optional<bool> fetch, bool yes, bool name_cfg, optional<bool> upgrade, // true - upgrade, false - patch @@ -894,7 +894,8 @@ namespace bdep // assert (c != nullptr); prjs.back ().configs.push_back ( - sync_project::config {c, true /* origin */, implicit, fetch}); + sync_project::config { + c, true /* origin */, implicit, fetch.has_value ()}); } } @@ -1600,7 +1601,11 @@ namespace bdep if (cfg.reps.empty ()) continue; - run_bpkg (3, co, "fetch", "-d", cfg.path.get (), "--shallow", cfg.reps); + run_bpkg (3, co, + "fetch", + "-d", cfg.path.get (), + (*fetch ? nullptr : "--shallow"), + cfg.reps); } string plan; @@ -2132,7 +2137,7 @@ namespace bdep const shared_ptr<configuration>& c, bool implicit, const strings& pkg_args, - bool fetch, + optional<bool> fetch, bool yes, bool name_cfg, const package_locations& prj_pkgs, @@ -2244,7 +2249,7 @@ namespace bdep move (lcfgs), pkg_args, implicit, - fetch, + fetch ? false /* shallow */ : optional<bool> (), yes, name_cfg, nullopt /* upgrade */, @@ -2292,7 +2297,7 @@ namespace bdep move (lcfgs), strings () /* pkg_args */, true /* implicit */, - fetch, + fetch ? false /* shallow */ : optional<bool> (), yes, name_cfg, nullopt /* upgrade */, @@ -2361,7 +2366,7 @@ namespace bdep move (lcfgs), strings () /* pkg_args */, true /* implicit */, - fetch, + fetch ? false /* shallow */ : optional<bool> (), yes, name_cfg, nullopt /* upgrade */, @@ -2391,7 +2396,7 @@ namespace bdep move (lcfgs), strings () /* pkg_args */, true /* implicit */, - true /* fetch */, + false /* shallow fetch */, true /* yes */, false /* name_cfg */, nullopt /* upgrade */, @@ -2738,7 +2743,7 @@ namespace bdep move (lcfgs), pkg_args, false /* implicit */, - !fetch, + !fetch ? false /* shallow */ : optional<bool> (), o.recursive () || o.immediate () ? o.yes () : true, false /* name_cfg */, !o.patch (), // Upgrade by default unless patch requested. @@ -2763,7 +2768,7 @@ namespace bdep move (lcfgs), pkg_args, false /* implicit */, - !fetch, + !fetch ? false /* shallow */ : optional<bool> (), o.yes (), false /* name_cfg */, o.upgrade (), @@ -2789,7 +2794,7 @@ namespace bdep move (lcfgs), pkg_args, o.implicit (), - !fetch, + !fetch ? false /* shallow */ : optional<bool> (), true /* yes */, o.implicit () /* name_cfg */, nullopt /* upgrade */, diff --git a/bdep/sync.hxx b/bdep/sync.hxx index 03ba105..f951a40 100644 --- a/bdep/sync.hxx +++ b/bdep/sync.hxx @@ -42,10 +42,10 @@ namespace bdep // If the origin project packages (prj_pkgs) are specified, then non-global // configuration variables are only applied to these packages. // - // If fetch is false, don't perform a (shallow) fetch of the project - // repository. If yes is false, then don't suppress bpkg prompts. If - // name_cfg is true then include the configuration name/directory into - // progress. + // If fetch_full is not nullopt, perform a fetch of the project repository, + // shallow if false and full if true. If yes is false, then don't suppress + // bpkg prompts. If name_cfg is true then include the configuration + // name/directory into progress. // // Before automatically creating a configuration for a build-time dependency // and associating it with the project(s), the user is prompted unless the @@ -92,7 +92,7 @@ namespace bdep const shared_ptr<configuration>&, bool implicit, const strings& pkg_args = strings (), - bool fetch = true, + optional<bool> fetch_full = false, // Shallow fetch. bool yes = true, bool name_cfg = false, const package_locations& prj_pkgs = {}, @@ -105,6 +105,9 @@ namespace bdep // As above but sync multiple configurations. If some configurations belong // to the same cluster, then they are synced at once. // + // Note: in the rest of cmd_sync() overloads, fetch is bool, with false + // meaning do not fetch and true -- fetch shallow. + // void cmd_sync (const common_options&, const dir_path& prj, diff --git a/tests/init.testscript b/tests/init.testscript index dac77f9..b49c171 100644 --- a/tests/init.testscript +++ b/tests/init.testscript @@ -353,6 +353,8 @@ status += -d prj $init -d libprj -A prj-cfg 2>>/~"%EOE%"; initializing in project $~/libprj/ added configuration $~/prj-cfg/ 1 target default,forwarded,auto-synchronized + %fetching .+% + %querying .+% synchronizing: % upgrade libprj.0.1.0-a.0.+#1% % reconfigure prj.0.1.0-a.0.19700101000000% @@ -426,6 +428,8 @@ status += -d prj added configuration $~/prj-cfg/ 1 target default,forwarded,auto-synchronized initializing package libprj initializing package libprj-extras + %fetching .+% + %querying .+% synchronizing: % upgrade libprj.0.1.0-a.0.+#1% % new libprj-extras.0.1.0-a.0.+% |