private async Task <(int UpdatesMade, bool?ThresholdReached)> DoTargetUpdates( IGitDriver git, RepositoryData repository, IReadOnlyCollection <PackageUpdateSet> targetUpdates, NuGetSources sources, SettingsContainer settings ) { if (targetUpdates.Count == 0) { return(0, null); } await _solutionRestore.CheckRestore(targetUpdates, settings.WorkingFolder ?? git.WorkingFolder, sources); var(updatesDone, thresholdReached) = await _packageUpdater.MakeUpdatePullRequests(git, repository, targetUpdates, sources, settings); if (updatesDone < targetUpdates.Count) { _logger.Minimal($"Attempted {targetUpdates.Count} updates and did {updatesDone}"); } else { _logger.Normal($"Done {updatesDone} updates"); } return(updatesDone, thresholdReached); }
private async Task <int> DoTargetUpdates( IGitDriver git, RepositoryData repository, IReadOnlyCollection <PackageUpdateSet> targetUpdates, NuGetSources sources, SettingsContainer settings) { if (targetUpdates.Count == 0) { _logger.Minimal("No updates can be applied. Exiting."); return(0); } await _solutionsRestore.CheckRestore(targetUpdates, settings.WorkingFolder ?? git.WorkingFolder, sources); var updatesDone = await _packageUpdater.MakeUpdatePullRequests(git, repository, targetUpdates, sources, settings); if (updatesDone < targetUpdates.Count) { _logger.Minimal($"Attempted {targetUpdates.Count} updates and did {updatesDone}"); } else { _logger.Normal($"Done {updatesDone} updates"); } return(updatesDone); }
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)); }
public static async Task CreatePullRequest( this IGitHub gitHub, RepositoryData repository, string title, string body, string branchWithChanges, IEnumerable <string> labels) { string qualifiedBranch; if (repository.Pull.Owner == repository.Push.Owner) { qualifiedBranch = branchWithChanges; } else { qualifiedBranch = repository.Push.Owner + ":" + branchWithChanges; } var pr = new NewPullRequest(title, qualifiedBranch, repository.DefaultBranch) { Body = body }; await gitHub.OpenPullRequest(repository.Pull, pr, labels); }
public async Task Run(IGitDriver git, RepositoryData repository) { GitInit(git, repository); var updates = await FindPackageUpdateSets(git); availableUpdatesReporter.Report(repository.Pull.Name, updates); if (updates.Count == 0) { _logger.Terse("No potential updates found. Well done. Exiting."); return; } var targetUpdates = _updateSelection.SelectTargets(git, 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"); }
private async Task <int> DoTargetUpdates( IGitDriver git, RepositoryData repository, IReadOnlyCollection <PackageUpdateSet> targetUpdates, NuGetSources sources) { if (targetUpdates.Count == 0) { _logger.Terse("No updates can be applied. Exiting."); return(0); } await _solutionsRestore.Restore(git.WorkingFolder, sources); var updatesDone = await UpdateAllTargets(git, repository, targetUpdates, sources); if (updatesDone < targetUpdates.Count) { _logger.Terse($"Attempted {targetUpdates.Count} updates and did {updatesDone}"); } else { _logger.Info($"Done {updatesDone} updates"); } return(updatesDone); }
private static async Task GitInit(IGitDriver git, RepositoryData repository) { await git.Clone(repository.Pull.Uri, repository.DefaultBranch); repository.DefaultBranch = repository.DefaultBranch ?? await git.GetCurrentHead(); await git.AddRemote(repository.Remote, repository.Push.Uri); }
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 UpdateAllTargets(IGitDriver git, RepositoryData repository, IEnumerable <PackageUpdateSet> targetUpdates) { foreach (var updateSet in targetUpdates) { await _packageUpdater.UpdatePackageInProjects(git, updateSet, repository); } }
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)); }
private async Task <int> UpdateAllTargets(IGitDriver git, RepositoryData repository, IEnumerable <PackageUpdateSet> targetUpdates, NuGetSources sources) { var updatesDone = 0; foreach (var updateSet in targetUpdates) { var success = await _packageUpdater.MakeUpdatePullRequest(git, updateSet, sources, repository); if (success) { updatesDone++; } } return(updatesDone); }
private static void GitInit(IGitDriver git, RepositoryData repository) { git.Clone(repository.Pull.Uri); repository.DefaultBranch = git.GetCurrentHead(); git.AddRemote(repository.Remote, repository.Push.Uri); }