From a2667426c166282746673fd8a21410edf3d1587e Mon Sep 17 00:00:00 2001 From: TheCakeIsNaOH Date: Thu, 28 Oct 2021 21:17:50 -0500 Subject: [PATCH] (#62) Allow disabling of the DefaultPushSource 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. --- .../infrastructure.app/commands/ChocolateyPushCommand.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs index fb59b5e4a..6ff134d31 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyPushCommand.cs @@ -121,6 +121,11 @@ public virtual void handle_validation(ChocolateyConfiguration configuration) throw new ApplicationException("Source is required. Please pass a source to push to, such as --source={0}".format_with(ApplicationParameters.ChocolateyCommunityFeedPushSource)); } + 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)); + } + var remoteSource = new Uri(configuration.Sources); if (string.IsNullOrWhiteSpace(configuration.PushCommand.Key) && !remoteSource.IsUnc && !remoteSource.IsFile)