Skip to content

Commit 98f8053

Browse files
committed
Merge branch 'stable'
* stable: (maint) Corrected whitespace (GH-1689) Delete packaging scripts before upgrade (doc) fix grammar in scripting guidelines (doc) add don't use nupkg to scripting guidelines (maint) fix typo (GH-1602) exit 2 on items outdated (doc) add step for rebasing prior to merging (GH-1614) Quote source name if includes pipe
2 parents faaf3e5 + cb2799b commit 98f8053

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

COMMITTERS.md

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Because we ask contributors to target master, sometimes a fix/enhancement may ne
7575
* `build.bat` - build and test
7676
* Any additional changes or testing here.
7777
* `git checkout stable`
78+
* `git fetch upstream` - if this pulls anything, make sure to also run `git rebase upstream/stable` prior to merging or you will lose the merge commit.
7879
* `git merge pr<github_pull_id> --log --no-ff`
7980
* `git branch -d pr<github_pull_id>`
8081
* `git checkout master`

src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,12 @@ shortcut commands like `cinst` or `cup`.
512512
`choco source list`, where `source` is the command and `list` is the
513513
subcommand.
514514
* Typically the subject comes next. If installing packages, the
515-
subject would be the package names. e.g. `choco install pkg1 pkg2`.
515+
subject would be the package names, e.g. `choco install pkg1 pkg2`.
516+
* Never use 'nupkg' or point directly to a nupkg file UNLESS using
517+
'choco push'. Use the source folder instead, e.g. `choco install
518+
<package id> --source=""'c:\folder\with\package'""` instead of
519+
`choco install DoNotDoThis.1.0.nupkg` or `choco install DoNotDoThis
520+
--source=""'c:\folder\with\package\DoNotDoThis.1.0.nupkg'""`.
516521
* Switches and parameters are called simply options. Options come
517522
after the subject. e.g. `choco install pkg1 --debug --verbose`.
518523
* Never use the force option (`--force`/`-f`) in scripts (or really
@@ -529,15 +534,15 @@ online or through `choco -?` /`choco [Command Name] -?`.
529534
temporarily stop for input - the key here is temporarily. They will
530535
continue without requiring any action after the temporary timeout
531536
(typically 30 seconds).
532-
* Full option names are prepended with two dashes. e.g. `--` or
537+
* Full option names are prepended with two dashes, e.g. `--` or
533538
`--debug --verbose --ignore-proxy`.
534539
* When setting a value to an option, always put an equals (`=`)
535540
between the name and the setting, e.g. `--source=""'local'""`.
536541
* When setting a value to an option, always surround the value
537-
properly with double quotes bookending apostrophes. e.g.
542+
properly with double quotes bookending apostrophes, e.g.
538543
`--source=""'internal_server'""`.
539544
* If you are building PowerShell scripts, you can most likely just
540-
simply use apostrophes surrounding option values e.g.
545+
simply use apostrophes surrounding option values, e.g.
541546
`--source='internal_server'`.
542547
* Prefer upgrade to install in scripts. You can't `install` to a newer
543548
version of something, but you can `choco upgrade` which will do both

src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public virtual IEnumerable<ChocolateySource> source_list(ChocolateyConfiguration
7575
else
7676
{
7777
this.Log().Info(() => "{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}".format_with(
78-
source.Id,
78+
source.Id.quote_if_pipe_found(),
7979
source.Value,
8080
source.Disabled.to_string(),
8181
source.UserName.quote_if_pipe_found(),

src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -633,29 +633,34 @@ Output is package name | current version | available version | pinned?
633633

634634
var output = config.RegularOutput;
635635
config.RegularOutput = false;
636-
var oudatedPackages = _nugetService.get_outdated(config);
636+
var outdatedPackages = _nugetService.get_outdated(config);
637637
config.RegularOutput = output;
638638

639639
if (config.RegularOutput)
640640
{
641-
var upgradeWarnings = oudatedPackages.Count(p => p.Value.Warning);
641+
var upgradeWarnings = outdatedPackages.Count(p => p.Value.Warning);
642642
this.Log().Warn(() => @"{0}{1} has determined {2} package(s) are outdated. {3}".format_with(
643643
Environment.NewLine,
644644
ApplicationParameters.Name,
645-
oudatedPackages.Count(p => p.Value.Success && !p.Value.Inconclusive),
645+
outdatedPackages.Count(p => p.Value.Success && !p.Value.Inconclusive),
646646
upgradeWarnings == 0 ? string.Empty : "{0} {1} package(s) had warnings.".format_with(Environment.NewLine, upgradeWarnings)
647647
));
648648

649649
if (upgradeWarnings != 0)
650650
{
651651
this.Log().Warn(ChocolateyLoggers.Important, "Warnings:");
652-
foreach (var warning in oudatedPackages.Where(p => p.Value.Warning).or_empty_list_if_null())
652+
foreach (var warning in outdatedPackages.Where(p => p.Value.Warning).or_empty_list_if_null())
653653
{
654654
this.Log().Warn(ChocolateyLoggers.Important, " - {0}".format_with(warning.Value.Name));
655655
}
656656
}
657657
}
658658

659+
if (outdatedPackages.Count != 0 && Environment.ExitCode == 0)
660+
{
661+
Environment.ExitCode = 2;
662+
}
663+
659664
randomly_notify_about_pro_business(config);
660665
}
661666

src/chocolatey/infrastructure.app/services/NugetService.cs

+28-3
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ public virtual ConcurrentDictionary<string, PackageResult> get_outdated(Chocolat
899899
var pkgInfo = _packageInfoService.get_package_information(installedPackage);
900900
bool isPinned = pkgInfo.IsPinned;
901901

902-
// if the package is pinned and we are skipping pinned,
902+
// if the package is pinned and we are skipping pinned,
903903
// move on quickly
904904
if (isPinned && config.OutdatedCommand.IgnorePinned)
905905
{
@@ -918,7 +918,7 @@ public virtual ConcurrentDictionary<string, PackageResult> get_outdated(Chocolat
918918
}
919919

920920
var latestPackage = find_package(packageName, null, config, repository);
921-
921+
922922
if (latestPackage == null)
923923
{
924924
if (config.Features.IgnoreUnfoundPackagesOnUpgradeOutdated) continue;
@@ -933,7 +933,7 @@ public virtual ConcurrentDictionary<string, PackageResult> get_outdated(Chocolat
933933
}
934934

935935
if (latestPackage.Version <= installedPackage.Version) continue;
936-
936+
937937
var packageResult = outdatedPackages.GetOrAdd(packageName, new PackageResult(latestPackage, _fileSystem.combine_paths(ApplicationParameters.PackagesLocation, latestPackage.Id)));
938938

939939
string logMessage = "You have {0} v{1} installed. Version {2} is available based on your source(s).{3} Source(s): \"{4}\"".format_with(installedPackage.Id, installedPackage.Version, latestPackage.Version, Environment.NewLine, config.Sources);
@@ -1146,6 +1146,8 @@ public virtual void backup_existing_version(ChocolateyConfiguration config, IPac
11461146
try
11471147
{
11481148
_fileSystem.copy_directory(backupLocation, pkgInstallPath, overwriteExisting: true);
1149+
1150+
remove_packaging_files_prior_to_upgrade(pkgInstallPath, config.CommandName);
11491151
}
11501152
catch (Exception ex)
11511153
{
@@ -1167,6 +1169,29 @@ process locking the folder or files. Please make sure nothing is
11671169
}
11681170
}
11691171

1172+
public virtual void remove_packaging_files_prior_to_upgrade(string directoryPath, string commandName)
1173+
{
1174+
if (commandName.to_lower() == "upgrade")
1175+
{
1176+
// Due to the way that Package Reducer works, there is a potential that a Chocolatey Packaging
1177+
// script could be incorrectly left in place during an upgrade operation. To guard against this,
1178+
// remove any Chocolatey Packaging scripts, which will then be restored by the new package, if
1179+
// they are still required
1180+
var filesToDelete = new List<string> {"chocolateyinstall", "chocolateyuninstall", "chocolateybeforemodify"};
1181+
var packagingScripts = _fileSystem.get_files(directoryPath, "*.ps1", SearchOption.AllDirectories)
1182+
.Where(p => filesToDelete.Contains(_fileSystem.get_file_name_without_extension(p).to_lower()));
1183+
1184+
foreach (var packagingScript in packagingScripts)
1185+
{
1186+
if (_fileSystem.file_exists(packagingScript))
1187+
{
1188+
this.Log().Debug("Deleting file {0}".format_with(packagingScript));
1189+
_fileSystem.delete_file(packagingScript);
1190+
}
1191+
}
1192+
}
1193+
}
1194+
11701195
public virtual void backup_changed_files(string packageInstallPath, ChocolateyConfiguration config, ChocolateyPackageInformation packageInfo)
11711196
{
11721197
if (packageInfo == null || packageInfo.Package == null) return;

0 commit comments

Comments
 (0)