Skip to content

Commit

Permalink
(chocolatey#62) Allow disabling of the DefaultPushSource
Browse files Browse the repository at this point in the history
If the DefaultPushSource is set to "disabled", this will throw an error
message saying that an source must be specified in the command.

As DefaultPushSource overrides the built-in default of
"ChocolateyCommunityFeedPushSource", the end behavior is that if it is
set to "disabled", then a source must be passed with --source.

This behavior is useful if a user wants has multiple repositories and
wants to always have to explicitly specify a source so as to make sure
to push package to the correct source.
  • Loading branch information
TheCakeIsNaOH committed Jan 7, 2023
1 parent d523981 commit e592ab4
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public virtual void handle_additional_argument_parsing(IList<string> unparsedArg
if (string.IsNullOrWhiteSpace(configuration.Sources) && !string.IsNullOrWhiteSpace(configuration.PushCommand.DefaultSource))
{
configuration.Sources = configuration.PushCommand.DefaultSource;

// Can't put this in handle_validation, since "disabled" is not a URI, it would fail earlier
if (configuration.Sources.is_equal_to("disabled"))
{
throw new ApplicationException("Default push source is disabled. Please pass a source to push to, such as --source={0}".format_with(ApplicationParameters.ChocolateyCommunityFeedPushSource));
}
}

if (string.IsNullOrWhiteSpace(configuration.Sources))
Expand Down

0 comments on commit e592ab4

Please sign in to comment.