private bool MatchesIncludeExclude(PackageUpdateSet packageUpdateSet) { return (MatchesInclude(_settings.Includes, packageUpdateSet) && !MatchesExclude(_settings.Excludes, packageUpdateSet)); }
private static bool MatchesInclude(Regex regex, PackageUpdateSet packageUpdateSet) { return(regex == null || regex.IsMatch(packageUpdateSet.SelectedId)); }
private static NuGetVersion MinCurrentVersion(PackageUpdateSet updates) { return(updates.CurrentPackages .Select(p => p.Version) .Min()); }
public static string MakeName(PackageUpdateSet updateSet) { return($"nukeeper-update-{updateSet.SelectedId}-to-{updateSet.SelectedVersion}"); }
private bool MatchesIncludeExclude(PackageUpdateSet packageUpdateSet) { return(RegexMatch.IncludeExclude(packageUpdateSet.SelectedId, _settings.Includes, _settings.Excludes)); }
private static string SelectedVersion(PackageUpdateSet packageUpdateSet) { return(packageUpdateSet.Selected.Identity.Version.ToString()); }
public static string MakePullRequestTitle(PackageUpdateSet updates) { return($"Automatic update of {updates.SelectedId} to {updates.SelectedVersion}"); }
private bool Match(PackageUpdateSet a, PackageUpdateSet b) { return(a.SelectedId == b.SelectedId); }
private static PackageDependency DependencyOn(PackageUpdateSet package) { return(new PackageDependency(package.SelectedId, new VersionRange(package.SelectedVersion))); }
private static string PackageVersionString(PackageUpdateSet updateSet) { return($"{updateSet.SelectedId}-v{updateSet.SelectedVersion}"); }
private static string MakeCommitVersionDetails(PackageUpdateSet updates) { var versionsInUse = updates.CurrentPackages .Select(u => u.Version) .Distinct() .ToList(); var oldVersions = versionsInUse .Select(v => CodeQuote(v.ToString())) .ToList(); var minOldVersion = versionsInUse.Min(); var newVersion = CodeQuote(updates.SelectedVersion.ToString()); var packageId = CodeQuote(updates.SelectedId); var changeLevel = ChangeLevel(minOldVersion, updates.SelectedVersion); var builder = new StringBuilder(); if (oldVersions.Count == 1) { builder.AppendLine($"NuKeeper has generated a {changeLevel} update of {packageId} to {newVersion} from {oldVersions.JoinWithCommas()}"); } else { builder.AppendLine($"NuKeeper has generated a {changeLevel} update of {packageId} to {newVersion}"); builder.AppendLine($"{oldVersions.Count} versions of {packageId} were found in use: {oldVersions.JoinWithCommas()}"); } if (updates.Selected.Published.HasValue) { var packageWithVersion = CodeQuote(updates.SelectedId + " " + updates.SelectedVersion); var pubDateString = CodeQuote(DateFormat.AsUtcIso8601(updates.Selected.Published)); var pubDate = updates.Selected.Published.Value.UtcDateTime; var ago = TimeSpanFormat.Ago(pubDate, DateTime.UtcNow); builder.AppendLine($"{packageWithVersion} was published at {pubDateString}, {ago}"); } var highestVersion = updates.Packages.Major?.Identity.Version; if (highestVersion != null && (highestVersion > updates.SelectedVersion)) { LogHighestVersion(updates, highestVersion, builder); } builder.AppendLine(); var updateOptS = (updates.CurrentPackages.Count > 1) ? "s" : string.Empty; builder.AppendLine($"### {updates.CurrentPackages.Count} project update{updateOptS}:"); builder.AppendLine("| Project | Package | From | To |"); builder.AppendLine("|:----------|:----------|-------:|-----:|"); foreach (var current in updates.CurrentPackages) { string line; if (SourceIsPublicNuget(updates.Selected.Source.SourceUri)) { line = $"| {CodeQuote(current.Path.RelativePath)} | {CodeQuote(updates.SelectedId)} | {NuGetVersionPackageLink(current.Identity)} | {NuGetVersionPackageLink(updates.Selected.Identity)} |"; builder.AppendLine(line); continue; } line = $"| {CodeQuote(current.Path.RelativePath)} | {CodeQuote(updates.SelectedId)} | {current.Version.ToString()} | {updates.SelectedVersion.ToString()} |"; builder.AppendLine(line); } return(builder.ToString()); }
public string MakeCommitMessage(PackageUpdateSet updates) { return($"{CommitEmoji} {PackageTitle(updates)}"); }
private static string PackageTitle(PackageUpdateSet updates) { return($"Automatic update of {updates.SelectedId} to {updates.SelectedVersion}"); }
private static Task <bool> Pass(PackageUpdateSet s) => Task.FromResult(true);
public static string MakeCommitMessage(PackageUpdateSet updates) { return($":{CommitEmoji}: {MakePullRequestTitle(updates)}"); }
private static Task <bool> Fail(PackageUpdateSet s) => Task.FromResult(false);
public static string MakeCommitDetails(PackageUpdateSet updates) { var versionsInUse = updates.CurrentPackages .Select(u => u.Version) .Distinct() .ToList(); var oldVersions = versionsInUse .Select(v => CodeQuote(v.ToString())) .ToList(); var minOldVersion = versionsInUse.Min(); var newVersion = CodeQuote(updates.SelectedVersion.ToString()); var packageId = CodeQuote(updates.SelectedId); var changeLevel = ChangeLevel(minOldVersion, updates.SelectedVersion); var builder = new StringBuilder(); if (oldVersions.Count == 1) { builder.AppendLine($"NuKeeper has generated a {changeLevel} update of {packageId} to {newVersion} from {oldVersions.JoinWithCommas()}"); } else { builder.AppendLine($"NuKeeper has generated a {changeLevel} update of {packageId} to {newVersion}"); builder.AppendLine($"{oldVersions.Count} versions of {packageId} were found in use: {oldVersions.JoinWithCommas()}"); } if (updates.Selected.Published.HasValue) { var packageWithVersion = CodeQuote(updates.SelectedId + " " + updates.SelectedVersion); var pubDateString = CodeQuote(DateFormat.AsUtcIso8601(updates.Selected.Published)); var pubDate = updates.Selected.Published.Value.UtcDateTime; var ago = TimeSpanFormat.Ago(pubDate, DateTime.UtcNow); builder.AppendLine($"{packageWithVersion} was published at {pubDateString}, {ago}"); } var highestVersion = updates.Packages.Major?.Identity.Version; if (highestVersion != null && (highestVersion > updates.SelectedVersion)) { LogHighestVersion(updates, highestVersion, builder); } builder.AppendLine(); if (updates.CurrentPackages.Count == 1) { builder.AppendLine("1 project update:"); } else { builder.AppendLine($"{updates.CurrentPackages.Count} project updates:"); } foreach (var current in updates.CurrentPackages) { var line = $"Updated {CodeQuote(current.Path.RelativePath)} to {packageId} {CodeQuote(updates.SelectedVersion.ToString())} from {CodeQuote(current.Version.ToString())}"; builder.AppendLine(line); } builder.AppendLine(); builder.AppendLine("This is an automated update. Merge only if it passes tests"); if (SourceIsPublicNuget(updates.Selected.Source)) { builder.AppendLine(); builder.AppendLine(NugetPackageLink(updates.Selected.Identity)); } builder.AppendLine("**NuKeeper**: https://github.com/NuKeeperDotNet/NuKeeper"); return(builder.ToString()); }
private static IReadOnlyCollection <PackageUpdateSet> PackageDeps(PackageUpdateSet set, IReadOnlyCollection <PackageUpdateSet> all) { var deps = set.Selected.Dependencies; return(all.Where(i => deps.Any(d => d.Id == i.SelectedId)).ToList()); }
public static string MakeCommitDetails(PackageUpdateSet updates) { var oldVersions = updates.CurrentPackages .Select(u => u.Version) .Distinct() .Select(v => CodeQuote(v.ToString())) .ToList(); var newVersion = CodeQuote(updates.SelectedVersion.ToString()); var packageId = CodeQuote(updates.SelectedId); var builder = new StringBuilder(); if (oldVersions.Count == 1) { builder.AppendLine($"NuKeeper has generated an update of {packageId} to {newVersion} from {oldVersions.JoinWithCommas()}"); } else { builder.AppendLine($"NuKeeper has generated an update of {packageId} to {newVersion}"); builder.AppendLine($"{oldVersions.Count} versions of {packageId} were found in use: {oldVersions.JoinWithCommas()}"); } if (updates.Selected.Published.HasValue) { var packageWithVersion = CodeQuote(updates.SelectedId + " " + updates.SelectedVersion); var pubDate = CodeQuote(DateFormat.AsUtcIso8601(updates.Selected.Published)); builder.AppendLine($"{packageWithVersion} was published at {pubDate}"); } var highestVersion = updates.HighestVersion; if (highestVersion != null && (highestVersion > updates.SelectedVersion)) { var allowedChange = CodeQuote(updates.AllowedChange.ToString()); var highest = CodeQuote(updates.SelectedId + " " + highestVersion); string highestPublishedAt = string.Empty; if (updates.Packages.Major.Published.HasValue) { highestPublishedAt = " published at " + CodeQuote(DateFormat.AsUtcIso8601(updates.Packages.Major.Published)); } builder.AppendLine( $"There is also a higher version, {highest}{highestPublishedAt}, but this was not applied as only {allowedChange} version changes are allowed."); } builder.AppendLine(); if (updates.CurrentPackages.Count == 1) { builder.AppendLine("1 project update:"); } else { builder.AppendLine($"{updates.CurrentPackages.Count} project updates:"); } foreach (var current in updates.CurrentPackages) { var line = $"Updated {CodeQuote(current.Path.RelativePath)} to {packageId} {CodeQuote(updates.SelectedVersion.ToString())} from {CodeQuote(current.Version.ToString())}"; builder.AppendLine(line); } builder.AppendLine(); builder.AppendLine("This is an automated update. Merge only if it passes tests"); builder.AppendLine("**NuKeeper**: https://github.com/NuKeeperDotNet/NuKeeper"); return(builder.ToString()); }