diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-14 14:58:54 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-14 14:58:54 +0200 |
commit | b44b4088f48a27bff88f8f010b8cd42303cbdad0 (patch) | |
tree | 46c08c1f48a81c3a4dc4c6c59be300e5e40e6762 /bdep/sync.cxx | |
parent | 7acf8ce6111e3740decd39b92c3383fcbdd00e21 (diff) |
Implement --fetch|-f and --fetch-full|-F in sync command
Diffstat (limited to 'bdep/sync.cxx')
-rw-r--r-- | bdep/sync.cxx | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/bdep/sync.cxx b/bdep/sync.cxx index 257cd20..dff6489 100644 --- a/bdep/sync.cxx +++ b/bdep/sync.cxx @@ -7,6 +7,8 @@ #include <bdep/database.hxx> #include <bdep/diagnostics.hxx> +#include <bdep/fetch.hxx> + using namespace std; namespace bdep @@ -14,7 +16,8 @@ namespace bdep void cmd_sync (const common_options& co, const dir_path& prj, - const shared_ptr<configuration>& c) + const shared_ptr<configuration>& c, + bool fetch) { assert (!c->packages.empty ()); @@ -30,11 +33,12 @@ namespace bdep // We also use the repository name rather than then location as a sanity // check (the repository must have been added as part of init). // - run_bpkg (co, - "fetch", - "-d", c->path, - "--shallow", - "dir:" + prj.string ()); + if (fetch) + run_bpkg (co, + "fetch", + "-d", c->path, + "--shallow", + "dir:" + prj.string ()); // Prepare the pkg-spec. // @@ -105,6 +109,7 @@ namespace bdep // Synchronize each configuration skipping empty ones. // + bool first (true); for (const shared_ptr<configuration>& c: cfgs) { if (c->packages.empty ()) @@ -115,7 +120,25 @@ namespace bdep continue; } - cmd_sync (o, prj, c); + // If we are synchronizing multiple configurations, separate them with a + // blank line and print the configuration name/directory. + // + if (verb && cfgs.size () > 1) + { + text << (first ? "" : "\n") + << "synchronizing with configuration " << *c; + + first = false; + } + + bool fetch (o.fetch () || o.fetch_full ()); + + if (fetch) + cmd_fetch (o, prj, c, o.fetch_full ()); + + // Don't re-fetch if we just fetched. + // + cmd_sync (o, prj, c, !fetch); } return 0; |