Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-604) Source Operations Should Respect Quiet
  (GH-603) Fix - Get-FileName errors sometimes
  • Loading branch information
ferventcoder committed Feb 4, 2016
2 parents 41741e2 + 978fab9 commit f13665c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ private static void add_or_remove_licensed_source(ChocolateyLicense license, Con
var addOrUpdate = license.IsValid;
var config = new ChocolateyConfiguration {
RegularOutput = false,
QuietOutput = true,
};

var sourceService = container.GetInstance<IChocolateyConfigSettingsService>();
Expand Down
4 changes: 2 additions & 2 deletions src/chocolatey.resources/helpers/functions/Get-FileName.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ param(

try
{
[HttpWebResponse]$response = $request.GetResponse()
[System.Net.HttpWebResponse]$response = $request.GetResponse()
if ($response -eq $null) {
$response.Close()
return $originalFileName
Expand Down Expand Up @@ -134,7 +134,7 @@ param(
{
$request.ServicePoint.MaxIdleTime = 0
$request.Abort();
Write-Debug "Url request/response failed - file name will be '$originalFileName'"
Write-Debug "Url request/response failed - file name will be '$originalFileName': $($_)"

return $originalFileName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace chocolatey.infrastructure.app.services
using System.Collections.Generic;
using System.Linq;
using configuration;
using infrastructure.configuration;
using infrastructure.services;
using logging;
using nuget;
Expand Down Expand Up @@ -50,7 +51,7 @@ public IEnumerable<ChocolateySource> source_list(ChocolateyConfiguration configu
var list = new List<ChocolateySource>();
foreach (var source in configFileSettings.Sources)
{
if (configuration.RegularOutput) {
if (!configuration.QuietOutput) {
this.Log().Info(() => "{0}{1} - {2} {3}| Priority {4}.".format_with(
source.Id,
source.Disabled ? " [Disabled]" : string.Empty,
Expand Down Expand Up @@ -85,7 +86,7 @@ public void source_add(ChocolateyConfiguration configuration)
configFileSettings.Sources.Add(source);

_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Added {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));
if (!configuration.QuietOutput) this.Log().Warn(() => "Added {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));
}
else
{
Expand All @@ -96,7 +97,7 @@ public void source_add(ChocolateyConfiguration configuration)
configuration.SourceCommand.Password.is_equal_to(currentPassword)
)
{
this.Log().Warn(NO_CHANGE_MESSAGE);
if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE);
}
else
{
Expand All @@ -106,7 +107,7 @@ public void source_add(ChocolateyConfiguration configuration)
source.Password = NugetEncryptionUtility.EncryptString(configuration.SourceCommand.Password);

_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Updated {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));
if (!configuration.QuietOutput) this.Log().Warn(() => "Updated {0} - {1} (Priority {2})".format_with(source.Id, source.Value, source.Priority));
}
}
}
Expand All @@ -119,11 +120,11 @@ public void source_remove(ChocolateyConfiguration configuration)
configFileSettings.Sources.Remove(source);
_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);

this.Log().Warn(() => "Removed {0}".format_with(source.Id));
if (!configuration.QuietOutput) this.Log().Warn(() => "Removed {0}".format_with(source.Id));
}
else
{
this.Log().Warn(NO_CHANGE_MESSAGE);
if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE);
}
}

Expand All @@ -134,11 +135,11 @@ public void source_disable(ChocolateyConfiguration configuration)
{
source.Disabled = true;
_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Disabled {0}".format_with(source.Id));
if (!configuration.QuietOutput) this.Log().Warn(() => "Disabled {0}".format_with(source.Id));
}
else
{
this.Log().Warn(NO_CHANGE_MESSAGE);
if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE);
}
}

Expand All @@ -149,11 +150,11 @@ public void source_enable(ChocolateyConfiguration configuration)
{
source.Disabled = false;
_xmlService.serialize(configFileSettings, ApplicationParameters.GlobalConfigFileLocation);
this.Log().Warn(() => "Enabled {0}".format_with(source.Id));
if (!configuration.QuietOutput) this.Log().Warn(() => "Enabled {0}".format_with(source.Id));
}
else
{
this.Log().Warn(NO_CHANGE_MESSAGE);
if (!configuration.QuietOutput) this.Log().Warn(NO_CHANGE_MESSAGE);
}
}

Expand Down

0 comments on commit f13665c

Please sign in to comment.