public static string ForUpdateSet(PackageUpdateSet update) { var occurrences = update.CurrentPackages.Count; var versionsInUse = update.CurrentPackages .Select(p => p.Version) .ToList(); var lowest = versionsInUse.Min(); var highest = versionsInUse.Max(); string versionInUse; if (lowest == highest) { versionInUse = highest.ToString(); } else { versionInUse = $"{lowest} - {highest}"; } var ago = "?"; if (update.Selected.Published.HasValue) { var pubDate = update.Selected.Published.Value.UtcDateTime; ago = TimeSpanFormat.Ago(pubDate, DateTime.UtcNow); } var optS = occurrences > 1 ? "s" : string.Empty; return($"{update.SelectedId} to {update.SelectedVersion} from {versionInUse} in {occurrences} place{optS} since {ago}."); }
private async Task <IReadOnlyCollection <PackageUpdateSet> > ApplyFilters( IReadOnlyCollection <PackageUpdateSet> all, Func <PackageUpdateSet, Task <bool> > remoteCheck) { var filteredByInOut = FilteredByIncludeExclude(all); var filteredLocally = filteredByInOut .Where(MatchesMinAge) .ToList(); if (filteredLocally.Count < filteredByInOut.Count) { var agoFormat = TimeSpanFormat.Ago(_settings.MinimumAge); _logger.Normal($"Filtered by minimum package age '{agoFormat}' from {filteredByInOut.Count} to {filteredLocally.Count}"); } var remoteFiltered = await ApplyRemoteFilter(filteredLocally, remoteCheck); if (remoteFiltered.Count < filteredLocally.Count) { _logger.Normal($"Filtered by remote branch check branch from {filteredLocally.Count} to {remoteFiltered.Count}"); } return(remoteFiltered); }
public void TestSomeHours() { var duration = new TimeSpan(9, 12, 3); var result = TimeSpanFormat.Ago(duration); Assert.That(result, Is.EqualTo("9 hours ago")); }
public void TestSomeSeconds() { var duration = new TimeSpan(0, 0, 32); var result = TimeSpanFormat.Ago(duration); Assert.That(result, Is.EqualTo("32 seconds ago")); }
public void TestSomeDays() { var duration = new TimeSpan(12, 9, 12, 3); var result = TimeSpanFormat.Ago(duration); Assert.That(result, Is.EqualTo("12 days ago")); }
public void TestAnHour() { var duration = new TimeSpan(1, 1, 1); var result = TimeSpanFormat.Ago(duration); Assert.That(result, Is.EqualTo("1 hour ago")); }
public void TestSomeMinutes() { var duration = new TimeSpan(0, 12, 3); var result = TimeSpanFormat.Ago(duration); Assert.That(result, Is.EqualTo("12 minutes ago")); }
public void TestYearStart() { var end = new DateTime(2018, 1, 1); var start = end.AddDays(-1); var result = TimeSpanFormat.Ago(start, end); Assert.That(result, Is.EqualTo("1 day ago")); }
public void TestTwoDatesMonthsApart() { var end = DateTime.UtcNow; var start = end.AddMonths(-4); var result = TimeSpanFormat.Ago(start, end); Assert.That(result, Is.EqualTo("4 months ago")); }
public void TestTwoDatesYearsApart() { var end = DateTime.UtcNow; var start = end.AddYears(-2); var result = TimeSpanFormat.Ago(start, end); Assert.That(result, Is.EqualTo("2 years ago")); }
public void TestTwoDatesSeperatedByTwoDays() { var end = DateTime.UtcNow; var start = end.AddDays(-2); var result = TimeSpanFormat.Ago(start, end); Assert.That(result, Is.EqualTo("2 days ago")); }
public void TestTwoDatesFourteenApart() { var end = new DateTime(2018, 3 ,4); var start = end.AddMonths(-14); var result = TimeSpanFormat.Ago(start, end); Assert.That(result, Is.EqualTo("1 year and 2 months ago")); }
public void TestTwoDatesTenMonthsApart() { var end = new DateTime(2018, 4,5); var start = end.AddMonths(-10); var result = TimeSpanFormat.Ago(start, end); Assert.That(result, Is.EqualTo("10 months ago")); }
public void TestTwoDatesThreeYearsAndOneMonthApart() { var end = DateTime.UtcNow; var start = end .AddYears(-3) .AddMonths(-1); var result = TimeSpanFormat.Ago(start, end); Assert.That(result, Is.EqualTo("3 years and 1 month ago")); }
private static string HighestPublishedAt(DateTimeOffset?highestPublishedAt) { if (!highestPublishedAt.HasValue) { return(string.Empty); } var highestPubDate = highestPublishedAt.Value; var formattedPubDate = CodeQuote(DateFormat.AsUtcIso8601(highestPubDate)); var highestAgo = TimeSpanFormat.Ago(highestPubDate.UtcDateTime, DateTime.UtcNow); return($" published at {formattedPubDate}, {highestAgo}"); }
private IReadOnlyCollection <PackageUpdateSet> ApplyFilters( IReadOnlyCollection <PackageUpdateSet> all) { var filtered = all .Where(MatchesMinAge) .ToList(); if (filtered.Count < all.Count) { var agoFormat = TimeSpanFormat.Ago(_settings.MinimumAge); _logger.Normal($"Filtered by minimum package age '{agoFormat}' from {all.Count} to {filtered.Count}"); } return(filtered); }
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(); 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); } if (SourceIsPublicNuget(updates.Selected.Source.SourceUri)) { builder.AppendLine(); builder.AppendLine(NugetPackageLink(updates.Selected.Identity)); } return(builder.ToString()); }