Skip to content

Commit

Permalink
upgrade: Make --keep-going the default (#308)
Browse files Browse the repository at this point in the history
* upgrade: Make --keep-going the default

* Apply code review feedback.

* Add message.

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
  • Loading branch information
autoantwort and BillyONeal authored Feb 18, 2022
1 parent f3841c4 commit 9e76536
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
2 changes: 0 additions & 2 deletions include/vcpkg/install.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ namespace vcpkg::Install
YES
};

inline KeepGoing to_keep_going(const bool value) { return value ? KeepGoing::YES : KeepGoing::NO; }

struct SpecSummary
{
SpecSummary(const PackageSpec& spec, const Dependencies::InstallPlanAction* action);
Expand Down
1 change: 1 addition & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"_GraphCycleDetectedElement.comment": "{LOCKED}",
"IllegalFeatures": "Error: List of features is not allowed in this contect",
"IllegalPlatformSpec": "Error: Platform qualifier is not allowed in this context",
"KeepGoingConflict": "The switches 'keep-going' and 'no-keep-going' cannot both be used",
"LicenseExpressionContainsExtraPlus": "SPDX license expression contains an extra '+'. These are only allowed directly after a license identifier.",
"LicenseExpressionContainsInvalidCharacter": "SPDX license expression contains an invalid character (0x{value:02x} '{value}').",
"LicenseExpressionContainsUnicode": "SPDX license expression contains a unicode character (U+{value:04x} '{pretty_value}'), but these expressions are ASCII-only.",
Expand Down
41 changes: 35 additions & 6 deletions src/vcpkg/commands.upgrade.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <vcpkg/base/lockguarded.h>
#include <vcpkg/base/messages.h>
#include <vcpkg/base/system.print.h>
#include <vcpkg/base/util.h>

Expand All @@ -17,18 +18,45 @@
#include <vcpkg/vcpkglib.h>
#include <vcpkg/vcpkgpaths.h>

namespace vcpkg::Commands::Upgrade
using namespace vcpkg;
using Install::KeepGoing;

namespace
{
using Install::KeepGoing;
using Install::to_keep_going;
DECLARE_AND_REGISTER_MESSAGE(KeepGoingConflict,
(),
"",
"The switches 'keep-going' and 'no-keep-going' cannot both be used");

KeepGoing determine_keep_going(bool keep_going_set, bool no_keep_going_set)
{
Checks::check_exit(VCPKG_LINE_INFO, !(keep_going_set && no_keep_going_set), msgKeepGoingConflict);
if (keep_going_set)
{
return KeepGoing::YES;
}

if (no_keep_going_set)
{
return KeepGoing::NO;
}

return KeepGoing::YES;
}
}

namespace vcpkg::Commands::Upgrade
{
static constexpr StringLiteral OPTION_NO_DRY_RUN = "no-dry-run";
// --keep-going is preserved for compatibility with old releases of vcpkg.
static constexpr StringLiteral OPTION_KEEP_GOING = "keep-going";
static constexpr StringLiteral OPTION_NO_KEEP_GOING = "no-keep-going";
static constexpr StringLiteral OPTION_ALLOW_UNSUPPORTED_PORT = "allow-unsupported";

static constexpr std::array<CommandSwitch, 3> INSTALL_SWITCHES = {{
static constexpr std::array<CommandSwitch, 4> INSTALL_SWITCHES = {{
{OPTION_NO_DRY_RUN, "Actually upgrade"},
{OPTION_KEEP_GOING, "Continue installing packages on failure"},
{OPTION_KEEP_GOING, ""},
{OPTION_NO_KEEP_GOING, "Stop installing packages on failure"},
{OPTION_ALLOW_UNSUPPORTED_PORT, "Instead of erroring on an unsupported port, continue with a warning."},
}};

Expand All @@ -55,7 +83,8 @@ namespace vcpkg::Commands::Upgrade
const ParsedArguments options = args.parse_arguments(COMMAND_STRUCTURE);

const bool no_dry_run = Util::Sets::contains(options.switches, OPTION_NO_DRY_RUN);
const KeepGoing keep_going = to_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING));
const KeepGoing keep_going = determine_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING),
Util::Sets::contains(options.switches, OPTION_NO_KEEP_GOING));
const auto unsupported_port_action = Util::Sets::contains(options.switches, OPTION_ALLOW_UNSUPPORTED_PORT)
? Dependencies::UnsupportedPortAction::Warn
: Dependencies::UnsupportedPortAction::Error;
Expand Down
5 changes: 3 additions & 2 deletions src/vcpkg/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,9 @@ namespace vcpkg::Install
Util::Sets::contains(options.switches, (OPTION_CLEAN_PACKAGES_AFTER_BUILD));
const bool clean_downloads_after_build =
Util::Sets::contains(options.switches, (OPTION_CLEAN_DOWNLOADS_AFTER_BUILD));
const KeepGoing keep_going =
to_keep_going(Util::Sets::contains(options.switches, OPTION_KEEP_GOING) || only_downloads);
const KeepGoing keep_going = Util::Sets::contains(options.switches, OPTION_KEEP_GOING) || only_downloads
? KeepGoing::YES
: KeepGoing::NO;
const bool prohibit_backcompat_features =
Util::Sets::contains(options.switches, (OPTION_PROHIBIT_BACKCOMPAT_FEATURES)) ||
Util::Sets::contains(options.switches, (OPTION_ENFORCE_PORT_CHECKS));
Expand Down

0 comments on commit 9e76536

Please sign in to comment.