public async Task <int> Run( IGitDriver git, RepositoryData repository, SettingsContainer settings) { GitInit(git, repository); var userSettings = settings.UserSettings; var sources = _nugetSourcesReader.Read(git.WorkingFolder, userSettings.NuGetSources); var updates = await _updateFinder.FindPackageUpdateSets( git.WorkingFolder, sources, userSettings.AllowedChange); _reporter.Report( userSettings.OutputDestination, userSettings.OutputFormat, repository.Pull.Name, userSettings.OutputFileName, updates); if (updates.Count == 0) { _logger.Minimal("No potential updates found. Well done. Exiting."); return(0); } var targetUpdates = await _updateSelection.SelectTargets( repository.Push, updates, settings.PackageFilters); return(await DoTargetUpdates(git, repository, targetUpdates, sources, settings)); }
private static LocalEngine MakeLocalEngine(IUpdateFinder finder, ILocalUpdater updater) { var reader = Substitute.For <INuGetSourcesReader>(); finder.FindPackageUpdateSets( Arg.Any <IFolder>(), Arg.Any <NuGetSources>(), Arg.Any <VersionChange>(), Arg.Any <UsePrerelease>()) .Returns(new List <PackageUpdateSet>()); var sorter = Substitute.For <IPackageUpdateSetSort>(); sorter.Sort(Arg.Any <IReadOnlyCollection <PackageUpdateSet> >()) .Returns(x => x.ArgAt <IReadOnlyCollection <PackageUpdateSet> >(0)); var logger = Substitute.For <INuKeeperLogger>(); var nugetLogger = Substitute.For <NuGet.Common.ILogger>(); var reporter = Substitute.For <IReporter>(); var engine = new LocalEngine(reader, finder, sorter, updater, reporter, logger, nugetLogger); Assert.That(engine, Is.Not.Null); return(engine); }
public async Task <int> Run( IGitDriver git, RepositoryData repository, SettingsContainer settings) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (git == null) { throw new ArgumentNullException(nameof(git)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (!repository.IsLocalRepo) { await GitInit(git, repository); } var userSettings = settings.UserSettings; var sources = _nugetSourcesReader.Read(settings.WorkingFolder ?? git.WorkingFolder, userSettings.NuGetSources); var updates = await _updateFinder.FindPackageUpdateSets( settings.WorkingFolder ?? git.WorkingFolder, sources, userSettings.AllowedChange, userSettings.UsePrerelease, settings.PackageFilters?.Includes, settings.PackageFilters?.Excludes); _reporter.Report( userSettings.OutputDestination, userSettings.OutputFormat, repository.Pull.Name, userSettings.OutputFileName, updates); if (updates.Count == 0) { _logger.Minimal("No potential updates found. Well done. Exiting."); return(0); } var targetUpdates = _updateSelection.SelectTargets( repository.Push, updates, settings.PackageFilters); return(await DoTargetUpdates(git, repository, targetUpdates, sources, settings)); }
private async Task<IReadOnlyCollection<PackageUpdateSet>> GetSortedUpdates( IFolder folder, NuGetSources sources, VersionChange allowedChange) { var updates = await _updateFinder.FindPackageUpdateSets( folder, sources, allowedChange); return _sorter.Sort(updates) .ToList(); }
private async Task <IReadOnlyCollection <PackageUpdateSet> > GetSortedUpdates( IFolder folder, NuGetSources sources, VersionChange allowedChange, UsePrerelease usePrerelease, Regex includes, Regex excludes) { var updates = await _updateFinder.FindPackageUpdateSets( folder, sources, allowedChange, usePrerelease, includes, excludes); return(_sorter.Sort(updates) .ToList()); }
public async Task Run(IGitDriver git, RepositoryData repository) { GitInit(git, repository); var updates = await _updateFinder.FindPackageUpdateSets(git.WorkingFolder); _logger.Verbose($"Report mode is {_settings.ReportMode}"); switch (_settings.ReportMode) { case ReportMode.Off: break; case ReportMode.On: // report and continue _availableUpdatesReporter.Report(repository.Pull.Name, updates); break; case ReportMode.ReportOnly: // report and exit _availableUpdatesReporter.Report(repository.Pull.Name, updates); _logger.Info("Exiting after reports only"); return; default: throw new Exception($"Unknown report mode: '{_settings.ReportMode}'"); } if (updates.Count == 0) { _logger.Terse("No potential updates found. Well done. Exiting."); return; } var targetUpdates = await _updateSelection.SelectTargets(repository.Push, updates); if (updates.Count == 0) { _logger.Terse("No updates can be applied. Exiting."); return; } await _solutionsRestore.Restore(git.WorkingFolder); await UpdateAllTargets(git, repository, targetUpdates); _logger.Info($"Done {targetUpdates.Count} Updates"); }
public async Task <int> Run( IGitDriver git, RepositoryData repository, SettingsContainer settings) { GitInit(git, repository); var sources = _nugetSourcesReader.Read(git.WorkingFolder, settings.UserSettings.NuGetSources); var updates = await _updateFinder.FindPackageUpdateSets( git.WorkingFolder, sources, settings.UserSettings.AllowedChange); _logger.Detailed($"Report mode is {settings.UserSettings.ReportMode}"); switch (settings.UserSettings.ReportMode) { case ReportMode.Off: break; case ReportMode.On: // report and continue _availableUpdatesReporter.Report(repository.Pull.Name, updates); break; case ReportMode.ReportOnly: // report and exit _availableUpdatesReporter.Report(repository.Pull.Name, updates); _logger.Normal("Exiting after reports only"); return(0); default: throw new Exception($"Unknown report mode: '{settings.UserSettings.ReportMode}'"); } if (updates.Count == 0) { _logger.Minimal("No potential updates found. Well done. Exiting."); return(0); } var targetUpdates = await _updateSelection.SelectTargets( repository.Push, updates, settings.PackageFilters); return(await DoTargetUpdates(git, repository, targetUpdates, sources, settings)); }
public void Initialize() { _packagesToReturn = new List <PackageUpdateSet>(); _sourcesReader = Substitute.For <INuGetSourcesReader>(); _nukeeperLogger = Substitute.For <INuKeeperLogger>(); _updateFinder = Substitute.For <IUpdateFinder>(); _packageUpdater = Substitute.For <IPackageUpdater>(); _updateFinder .FindPackageUpdateSets( Arg.Any <IFolder>(), Arg.Any <NuGetSources>(), Arg.Any <VersionChange>(), Arg.Any <UsePrerelease>(), Arg.Any <Regex>() ) .Returns(_packagesToReturn); }