Skip to content

Instantly share code, notes, and snippets.

@skarllot
Created May 19, 2024 14:05
Show Gist options
  • Save skarllot/8fcda44a9fd2d356c15bb63fec2246d7 to your computer and use it in GitHub Desktop.
Save skarllot/8fcda44a9fd2d356c15bb63fec2246d7 to your computer and use it in GitHub Desktop.
Remove duplicates from GitHub release notes
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"string content = @\"* ci(github-action): update actions/upload-artifact action to v4.3.3 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/133\n",
"* ci(github-action): update github/codeql-action action to v3.25.2 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/134\n",
"* ci(github-action): update actions/checkout action to v4.1.4 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/135\n",
"* build(deps): update dependency dotnet-stryker to v4.0.5 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/120\n",
"* ci(github-action): update github/codeql-action action to v3.25.3 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/136\n",
"* build(deps): update xunit.net to v2.8.0 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/137\n",
"* ci(github-action): update step-security/harden-runner action to v2.7.1 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/138\n",
"* ci(github-action): update actions/dependency-review-action action to v4.3.2 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/139\n",
"* ci(github-action): update codecov/codecov-action action to v4.3.1 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/141\n",
"* ci(github-action): update actions/checkout action to v4.1.5 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/142\n",
"* build(deps): update dependency azure.identity to v1.11.3 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/143\n",
"* ci(github-action): update github/codeql-action action to v3.25.4 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/144\n",
"* ci(github-action): update ossf/scorecard-action action to v2.3.3 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/145\n",
"* ci(github-action): update github/codeql-action action to v3.25.5 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/146\n",
"* build(deps): update dependency dotnet-sdk to v8.0.300 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/147\n",
"* build(deps): update dependency swashbuckle.aspnetcore to v6.6.1 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/148\n",
"* ci(github-action): update codecov/codecov-action action to v4.4.0 by @renovate in https://github.com/skarllot/azure-keyvault-reference/pull/149\";"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [],
"source": [
"using System.Text.RegularExpressions;\n",
"\n",
"var prPattern = @\"https://github[.]com/[A-z0-9\\-]+/[A-z0-9\\-]+/pull/\";\n",
"\n",
"content = Regex.Replace(content, prPattern, \"#\");"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [
{
"data": {
"text/plain": [
"Unknown keys: 0"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<table><thead><tr><th><i>index</i></th><th>value</th></tr></thead><tbody><tr><td>0</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = actions/upload-artifact, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>actions/upload-artifact</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>1</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = github/codeql-action, Count = 4 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>github/codeql-action</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>4</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>2</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = actions/checkout, Count = 2 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>actions/checkout</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>2</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>3</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = dotnet-stryker, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>dotnet-stryker</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>4</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = xunit.net, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>xunit.net</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>5</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = step-security/harden-runner, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>step-security/harden-runner</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>6</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = actions/dependency-review-action, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>actions/dependency-review-action</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>7</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = codecov/codecov-action, Count = 2 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>codecov/codecov-action</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>2</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>8</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = azure.identity, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>azure.identity</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>9</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = ossf/scorecard-action, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>ossf/scorecard-action</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>10</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = dotnet-sdk, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>dotnet-sdk</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr><tr><td>11</td><td><details class=\"dni-treeview\"><summary><span class=\"dni-code-hint\"><code>{ Key = swashbuckle.aspnetcore, Count = 1 }</code></span></summary><div><table><thead><tr></tr></thead><tbody><tr><td>Key</td><td><div class=\"dni-plaintext\"><pre>swashbuckle.aspnetcore</pre></div></td></tr><tr><td>Count</td><td><div class=\"dni-plaintext\"><pre>1</pre></div></td></tr></tbody></table></div></details></td></tr></tbody></table><style>\r\n",
".dni-code-hint {\r\n",
" font-style: italic;\r\n",
" overflow: hidden;\r\n",
" white-space: nowrap;\r\n",
"}\r\n",
".dni-treeview {\r\n",
" white-space: nowrap;\r\n",
"}\r\n",
".dni-treeview td {\r\n",
" vertical-align: top;\r\n",
" text-align: start;\r\n",
"}\r\n",
"details.dni-treeview {\r\n",
" padding-left: 1em;\r\n",
"}\r\n",
"table td {\r\n",
" text-align: start;\r\n",
"}\r\n",
"table tr { \r\n",
" vertical-align: top; \r\n",
" margin: 0em 0px;\r\n",
"}\r\n",
"table tr td pre \r\n",
"{ \r\n",
" vertical-align: top !important; \r\n",
" margin: 0em 0px !important;\r\n",
"} \r\n",
"table th {\r\n",
" text-align: start;\r\n",
"}\r\n",
"</style>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"using System.Text.RegularExpressions;\n",
"\n",
"var keyPattern = @\": (update|bump|pin)( dependency)? (([A-z0-9\\-/.:]+|[a-z ]+))( docker digest)?( action)?( from [^ ]+)?( to [^ ]+)?( in [^ ]+)? by @\";\n",
"\n",
"var values = content.Split(\"\\n\").Select(x => new {\n",
" Key = Regex.Match(x, keyPattern).Groups[3].Value,\n",
" Value = x,\n",
" PR = int.Parse(Regex.Match(x, @\"in #(\\d+)\").Groups[1].Value) });\n",
"\n",
"display($\"Unknown keys: {values.Count(x => string.IsNullOrWhiteSpace(x.Key))}\");\n",
"display(values.GroupBy(x => x.Key).Select(x => new { Key = x.Key, Count = x.Count() }));\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"dotnet_interactive": {
"language": "csharp"
},
"polyglot_notebook": {
"kernelName": "csharp"
},
"vscode": {
"languageId": "polyglot-notebook"
}
},
"outputs": [
{
"data": {
"text/plain": [
"* build(deps): update dependency dotnet-stryker to v4.0.5 by @renovate in #120\r\n",
"* ci(github-action): update actions/upload-artifact action to v4.3.3 by @renovate in #133\r\n",
"* build(deps): update xunit.net to v2.8.0 by @renovate in #137\r\n",
"* ci(github-action): update step-security/harden-runner action to v2.7.1 by @renovate in #138\r\n",
"* ci(github-action): update actions/dependency-review-action action to v4.3.2 by @renovate in #139\r\n",
"* ci(github-action): update actions/checkout action to v4.1.5 by @renovate in #142\r\n",
"* build(deps): update dependency azure.identity to v1.11.3 by @renovate in #143\r\n",
"* ci(github-action): update ossf/scorecard-action action to v2.3.3 by @renovate in #145\r\n",
"* ci(github-action): update github/codeql-action action to v3.25.5 by @renovate in #146\r\n",
"* build(deps): update dependency dotnet-sdk to v8.0.300 by @renovate in #147\r\n",
"* build(deps): update dependency swashbuckle.aspnetcore to v6.6.1 by @renovate in #148\r\n",
"* ci(github-action): update codecov/codecov-action action to v4.4.0 by @renovate in #149"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"var result = values\n",
" .GroupBy(x => x.Key)\n",
" .Select(x => new { Value = x.MaxBy(y => y.PR).Value, PR = x.MaxBy(y => y.PR).PR })\n",
" .OrderBy(x => x.PR)\n",
" .Select(x => x.Value);\n",
"\n",
"display(string.Join(\"\\n\", result));"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".NET (C#)",
"language": "C#",
"name": ".net-csharp"
},
"language_info": {
"name": "C#"
},
"polyglot_notebook": {
"kernelInfo": {
"defaultKernelName": "csharp",
"items": [
{
"aliases": [],
"name": "csharp"
}
]
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment