Skip to content

Commit

Permalink
Merge pull request #84 from nils-a/release/0.2.0
Browse files Browse the repository at this point in the history
Release/0.2.0
  • Loading branch information
nils-a authored Oct 27, 2023
2 parents 06b2e5d + 3fa52ab commit 581fa72
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "github>nils-a/renovate-config" ]
}
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [ "github>nils-org/renovate-config" ]
}
16 changes: 8 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ jobs:
#WYAM_DEPLOY_REMOTE: ${{ github.event.repository.html_url }}

steps:
- name: Checkout the repository
uses: actions/checkout@v3.1.0
- name: Checkout the repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Fetch all tags and branches
run: git fetch --prune --unshallow
- name: Setup .NET
uses: actions/setup-dotnet@v3.0.3
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
with:
dotnet-version: |
2.1.818
Expand All @@ -54,26 +54,26 @@ jobs:
6.0.x
7.0.x
- name: Cache Tools
uses: actions/cache@v3.0.11
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: tools
key: ${{ runner.os }}-tools-${{ hashFiles('recipe.cake') }}
- name: Build project
uses: cake-build/[email protected]
uses: cake-build/cake-action@a6eb054329257c9e70a6c6bf01747ad6e1d9d52b # v1.4.1
with:
script-path: recipe.cake
target: CI
cake-version: 1.3.0
cake-version: tool-manifest
- name: Upload Issues
uses: actions/[email protected].1
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
if-no-files-found: warn
name: ${{ matrix.os }} Issues
path: |
BuildArtifacts/report.html
BuildArtifacts/**/coverlet/*.xml
- name: Upload Packages
uses: actions/[email protected].1
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: runner.os == 'Windows'
with:
if-no-files-found: warn
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "7.0.403",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion recipe.cake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#load nuget:?package=Cake.Recipe&version=3.0.1
#load nuget:?package=Cake.Recipe&version=3.1.1

var standardNotificationMessage = "Version {0} of {1} has just been released, it will be available here https://www.nuget.org/packages/{1}, once package indexing is complete.";

Expand Down
38 changes: 32 additions & 6 deletions src/GitHubMilestoneCleaner/Commands/AutoCleanupCommand.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
Expand Down Expand Up @@ -113,16 +114,41 @@ public override async Task<int> ExecuteAsync(CommandContext context, Settings se
return 0;
}

foreach (var issue in toRemove)
async Task DoRemove(Action? callback = null)
{
var group = grouped.First(g => g.MainIssue.Id == issue.Id || g.SubIssues.Any(i => i.Id == issue.Id));
var comment = issue == group.MainIssue ? settings.TopIssueComment : settings.SubIssueComment;
if (!string.IsNullOrEmpty(comment))
foreach (var issue in toRemove)
{
comment = string.Format(comment, group.MainIssue.HtmlUrl);
var group = grouped.First(g => g.MainIssue.Id == issue.Id || g.SubIssues.Any(i => i.Id == issue.Id));
var comment = issue == group.MainIssue ? settings.TopIssueComment : settings.SubIssueComment;
if (!string.IsNullOrEmpty(comment))
{
comment = string.Format(comment, group.MainIssue.HtmlUrl);
}

await adapter.RemoveMilestone(repo, issue, comment);
callback?.Invoke();
}
}

if (settings.NonInteractive)
{
await DoRemove();
}
else
{
await AnsiConsole.Progress()
.StartAsync(async ctx =>
{
var inc = 100d / toRemove.Count;
var task = ctx.AddTask($"Cleaning {toRemove.Count} issues");
await DoRemove(() =>
{
task.Increment(inc);
});

await adapter.RemoveMilestone(repo, issue, comment);
var rest = 100 - task.Percentage;
task.Increment(rest);
});
}

return 0;
Expand Down
18 changes: 14 additions & 4 deletions src/GitHubMilestoneCleaner/Engines/IssueGroupEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,27 @@ namespace GitHubMilestoneCleaner.Engines;
public class IssueGroupEngine
{
private readonly Regex _versionMatcher =
new Regex(
@"(0|[1-9]\d*)(\.(0|[1-9]\d*))+(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?");
new(
@"\s*(from|to) v?(0|[1-9]\d*)(\.(0|[1-9]\d*))+(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?");
private readonly Regex _digestMatcher = new(@"\s*digest to [0-9a-fA-F]+$");


public IEnumerable<IssueGroup> GroupIssues(IEnumerable<Issue> issues)
{

var matchers = new[]
{
_versionMatcher,
_digestMatcher
};

return issues
.Select(x => new
{
Issue = x,
VersionAgnosticName = _versionMatcher.Replace(x.Title, string.Empty)
VersionAgnosticName = (matchers
.FirstOrDefault(m => m.IsMatch(x.Title))?
.Replace(x.Title, string.Empty) ?? x.Title)
.TrimEnd(),
})
.GroupBy(x => x.VersionAgnosticName)
.Select(x =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ public static class GitHubClientExtensions

return TimeSpan.FromSeconds(secondsToWait);
},
async (ex, _, _, ctx) =>
(ex, _, _, ctx) =>
{
var cancellationTokenSource = (CancellationTokenSource)ctx[CancellationTokenSourceKey];
if (ex is Octokit.NotFoundException)
{
AnsiConsole.MarkupLine($"[red]{ex.GetType().Name}: {ex.Message}[/]");
cancellationTokenSource.Cancel();
}

return Task.CompletedTask;
});

public static async Task<T> WithRetry<T>(
Expand Down
10 changes: 5 additions & 5 deletions src/GitHubMilestoneCleaner/GitHubMilestoneCleaner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
<PackageReference Include="Octokit" Version="4.0.2" />
<PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Spectre.Console" Version="0.45.1-preview.0.43" />
<PackageReference Include="Spectre.Console.Cli" Version="0.45.1-preview.0.43" />
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0" />
<PackageReference Include="Octokit" Version="8.1.1" />
<PackageReference Include="Polly" Version="8.0.0" />
<PackageReference Include="Spectre.Console" Version="0.47.0" />
<PackageReference Include="Spectre.Console.Cli" Version="0.47.0" />
</ItemGroup>
</Project>

0 comments on commit 581fa72

Please sign in to comment.