From 11fed38dff702313c5dbf62b6d0de7c3123441f0 Mon Sep 17 00:00:00 2001 From: hzhang Date: Thu, 1 May 2025 23:01:29 +0100 Subject: [PATCH] add: terminal tool --- .../.idea/.gitignore | 13 +++++++ .idea/.idea.Alchegos.Webhook/.idea/.gitignore | 13 +++++++ Alchegos.Webhook.csproj | 2 +- AlchegosEventDispatcher.cs | 2 +- Dockerfile | 12 +++--- GiteaEventDispatcher.cs | 5 ++- .../IAlchegosEventHandler.cs | 2 +- .../ProjectPlanEventHandler.cs | 12 ++++++ .../IGiteaEventHandler.cs | 2 +- .../IssueCommentEventHandler.cs | 4 +- .../IssuesEventHandler.cs | 2 +- .../PullRequestEventHandler.cs | 2 +- .../PushEventHandler.cs | 2 +- Handlers/IWebhookEventHandler.cs | 2 +- Handlers/ProjectPlanEventHandler.cs | 3 +- Program.cs | 2 +- Properties/launchSettings.json | 2 +- summerizer | 37 +++++++++++++++++++ 18 files changed, 98 insertions(+), 21 deletions(-) create mode 100644 .idea/.idea.Alchegos.Gitea.Webhook/.idea/.gitignore create mode 100644 .idea/.idea.Alchegos.Webhook/.idea/.gitignore rename Handlers/{ => AlchegosEventHandlers}/IAlchegosEventHandler.cs (54%) create mode 100644 Handlers/AlchegosEventHandlers/ProjectPlanEventHandler.cs rename Handlers/{ => GiteaEventHandlers}/IGiteaEventHandler.cs (54%) rename Handlers/{ => GiteaEventHandlers}/IssueCommentEventHandler.cs (85%) rename Handlers/{ => GiteaEventHandlers}/IssuesEventHandler.cs (97%) rename Handlers/{ => GiteaEventHandlers}/PullRequestEventHandler.cs (97%) rename Handlers/{ => GiteaEventHandlers}/PushEventHandler.cs (95%) create mode 100755 summerizer diff --git a/.idea/.idea.Alchegos.Gitea.Webhook/.idea/.gitignore b/.idea/.idea.Alchegos.Gitea.Webhook/.idea/.gitignore new file mode 100644 index 0000000..f253775 --- /dev/null +++ b/.idea/.idea.Alchegos.Gitea.Webhook/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/modules.xml +/contentModel.xml +/projectSettingsUpdater.xml +/.idea.Alchegos.Gitea.Webhook.iml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.idea.Alchegos.Webhook/.idea/.gitignore b/.idea/.idea.Alchegos.Webhook/.idea/.gitignore new file mode 100644 index 0000000..85f0932 --- /dev/null +++ b/.idea/.idea.Alchegos.Webhook/.idea/.gitignore @@ -0,0 +1,13 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Rider ignored files +/projectSettingsUpdater.xml +/.idea.Alchegos.Webhook.iml +/contentModel.xml +/modules.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/Alchegos.Webhook.csproj b/Alchegos.Webhook.csproj index ee6b80a..0c3292c 100644 --- a/Alchegos.Webhook.csproj +++ b/Alchegos.Webhook.csproj @@ -12,8 +12,8 @@ .dockerignore + - diff --git a/AlchegosEventDispatcher.cs b/AlchegosEventDispatcher.cs index b920816..5a382aa 100644 --- a/AlchegosEventDispatcher.cs +++ b/AlchegosEventDispatcher.cs @@ -1,4 +1,4 @@ -namespace Alchegos.Gitea.Webhook; +namespace Alchegos.Webhook; public class AlchegosEventDispatcher { diff --git a/Dockerfile b/Dockerfile index 59027c7..3784a10 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,17 +7,17 @@ EXPOSE 8080 FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src -COPY ["Alchegos.Gitea.Webhook/Alchegos.Gitea.Webhook.csproj", "Alchegos.Gitea.Webhook/"] -RUN dotnet restore "Alchegos.Gitea.Webhook/Alchegos.Gitea.Webhook.csproj" +COPY ["Alchegos.Webhook.csproj", "./"] +RUN dotnet restore "Alchegos.Webhook.csproj" COPY . . -WORKDIR "/src/Alchegos.Gitea.Webhook" -RUN dotnet build "Alchegos.Gitea.Webhook.csproj" -c $BUILD_CONFIGURATION -o /app/build +WORKDIR "/src/Alchegos.Webhook" +RUN dotnet build "/src/Alchegos.Webhook.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "Alchegos.Gitea.Webhook.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "Alchegos.Webhook.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Alchegos.Gitea.Webhook.dll"] +ENTRYPOINT ["dotnet", "Alchegos.Webhook.dll"] diff --git a/GiteaEventDispatcher.cs b/GiteaEventDispatcher.cs index 7b78038..cb20b98 100644 --- a/GiteaEventDispatcher.cs +++ b/GiteaEventDispatcher.cs @@ -1,8 +1,9 @@ using System.Text.Json.Nodes; using Alchegos.Core.Services.RabbitMQ; -using Alchegos.Gitea.Webhook.Handlers; +using Alchegos.Webhook.Handlers; +using Alchegos.Webhook.Handlers.GiteaEventHandlers; -namespace Alchegos.Gitea.Webhook; +namespace Alchegos.Webhook; public class GiteaEventDispatcher { diff --git a/Handlers/IAlchegosEventHandler.cs b/Handlers/AlchegosEventHandlers/IAlchegosEventHandler.cs similarity index 54% rename from Handlers/IAlchegosEventHandler.cs rename to Handlers/AlchegosEventHandlers/IAlchegosEventHandler.cs index 3442df1..824ed8a 100644 --- a/Handlers/IAlchegosEventHandler.cs +++ b/Handlers/AlchegosEventHandlers/IAlchegosEventHandler.cs @@ -1,4 +1,4 @@ -namespace Alchegos.Gitea.Webhook.Handlers; +namespace Alchegos.Webhook.Handlers.AlchegosEventHandlers; public interface IAlchegosEventHandler : IWebhookEventHandler { diff --git a/Handlers/AlchegosEventHandlers/ProjectPlanEventHandler.cs b/Handlers/AlchegosEventHandlers/ProjectPlanEventHandler.cs new file mode 100644 index 0000000..9ead806 --- /dev/null +++ b/Handlers/AlchegosEventHandlers/ProjectPlanEventHandler.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Nodes; +using Alchegos.Core.Services.RabbitMQ; + +namespace Alchegos.Webhook.Handlers.AlchegosEventHandlers; + +public class ProjectPlanEventHandler : IAlchegosEventHandler +{ + public Task HandleAsync(JsonNode payload, IRabbitPublisher publisher) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/Handlers/IGiteaEventHandler.cs b/Handlers/GiteaEventHandlers/IGiteaEventHandler.cs similarity index 54% rename from Handlers/IGiteaEventHandler.cs rename to Handlers/GiteaEventHandlers/IGiteaEventHandler.cs index 3eec880..9fc1beb 100644 --- a/Handlers/IGiteaEventHandler.cs +++ b/Handlers/GiteaEventHandlers/IGiteaEventHandler.cs @@ -1,4 +1,4 @@ -namespace Alchegos.Gitea.Webhook.Handlers; +namespace Alchegos.Webhook.Handlers.GiteaEventHandlers; public interface IGiteaEventHandler: IWebhookEventHandler { diff --git a/Handlers/IssueCommentEventHandler.cs b/Handlers/GiteaEventHandlers/IssueCommentEventHandler.cs similarity index 85% rename from Handlers/IssueCommentEventHandler.cs rename to Handlers/GiteaEventHandlers/IssueCommentEventHandler.cs index 827acb5..4cbb967 100644 --- a/Handlers/IssueCommentEventHandler.cs +++ b/Handlers/GiteaEventHandlers/IssueCommentEventHandler.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Nodes; using Alchegos.Core.Services.RabbitMQ; -namespace Alchegos.Gitea.Webhook.Handlers; +namespace Alchegos.Webhook.Handlers.GiteaEventHandlers; public class IssueCommentEventHandler : IGiteaEventHandler { @@ -11,7 +11,7 @@ public class IssueCommentEventHandler : IGiteaEventHandler if (payload["action"]?.ToString() != "created") return; - var message = new Dictionary + Dictionary message = new Dictionary { {"repo_url", payload["repository"]?["url"]?.ToString()}, {"repo_owner", payload["repository"]?["owner"]?["login"]?.ToString()}, diff --git a/Handlers/IssuesEventHandler.cs b/Handlers/GiteaEventHandlers/IssuesEventHandler.cs similarity index 97% rename from Handlers/IssuesEventHandler.cs rename to Handlers/GiteaEventHandlers/IssuesEventHandler.cs index da55969..30ba697 100644 --- a/Handlers/IssuesEventHandler.cs +++ b/Handlers/GiteaEventHandlers/IssuesEventHandler.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Nodes; using Alchegos.Core.Services.RabbitMQ; -namespace Alchegos.Gitea.Webhook.Handlers; +namespace Alchegos.Webhook.Handlers.GiteaEventHandlers; public class IssuesEventHandler : IGiteaEventHandler { diff --git a/Handlers/PullRequestEventHandler.cs b/Handlers/GiteaEventHandlers/PullRequestEventHandler.cs similarity index 97% rename from Handlers/PullRequestEventHandler.cs rename to Handlers/GiteaEventHandlers/PullRequestEventHandler.cs index c79d952..01b4c67 100644 --- a/Handlers/PullRequestEventHandler.cs +++ b/Handlers/GiteaEventHandlers/PullRequestEventHandler.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Nodes; using Alchegos.Core.Services.RabbitMQ; -namespace Alchegos.Gitea.Webhook.Handlers; +namespace Alchegos.Webhook.Handlers.GiteaEventHandlers; public class PullRequestEventHandler : IGiteaEventHandler { diff --git a/Handlers/PushEventHandler.cs b/Handlers/GiteaEventHandlers/PushEventHandler.cs similarity index 95% rename from Handlers/PushEventHandler.cs rename to Handlers/GiteaEventHandlers/PushEventHandler.cs index 92631de..4ad139a 100644 --- a/Handlers/PushEventHandler.cs +++ b/Handlers/GiteaEventHandlers/PushEventHandler.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Nodes; using Alchegos.Core.Services.RabbitMQ; -namespace Alchegos.Gitea.Webhook.Handlers; +namespace Alchegos.Webhook.Handlers.GiteaEventHandlers; public class PushEventHandler : IGiteaEventHandler { diff --git a/Handlers/IWebhookEventHandler.cs b/Handlers/IWebhookEventHandler.cs index a8bcce9..967a103 100644 --- a/Handlers/IWebhookEventHandler.cs +++ b/Handlers/IWebhookEventHandler.cs @@ -1,7 +1,7 @@ using System.Text.Json.Nodes; using Alchegos.Core.Services.RabbitMQ; -namespace Alchegos.Gitea.Webhook.Handlers; +namespace Alchegos.Webhook.Handlers; public interface IWebhookEventHandler { diff --git a/Handlers/ProjectPlanEventHandler.cs b/Handlers/ProjectPlanEventHandler.cs index adcf791..9e51d9d 100644 --- a/Handlers/ProjectPlanEventHandler.cs +++ b/Handlers/ProjectPlanEventHandler.cs @@ -1,8 +1,9 @@ using System.Text.Json; using System.Text.Json.Nodes; using Alchegos.Core.Services.RabbitMQ; +using Alchegos.Webhook.Handlers.GiteaEventHandlers; -namespace Alchegos.Gitea.Webhook.Handlers; +namespace Alchegos.Webhook.Handlers; public class ProjectPlanEventHandler : IGiteaEventHandler { diff --git a/Program.cs b/Program.cs index efc018a..22ebd54 100644 --- a/Program.cs +++ b/Program.cs @@ -1,7 +1,7 @@ using System.Text.Json.Nodes; using Alchegos.Core; using Alchegos.Core.Services.RabbitMQ; -using Alchegos.Gitea.Webhook; +using Alchegos.Webhook; GlobalRegistry.Instance.Start(); diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 287d7e0..7c59053 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/launchsettings.json", "profiles": { - "Alchegos.Gitea.Webhook": { + "Alchegos.Webhook": { "commandName": "Project", "dotnetRunMessages": true, "environmentVariables": { diff --git a/summerizer b/summerizer new file mode 100755 index 0000000..c7aad2c --- /dev/null +++ b/summerizer @@ -0,0 +1,37 @@ +#!/usr/bin/python3 +import os + +ignores = [ + 'bin', + 'obj', + '.godot', + '.idea', + 'icon.svg', + 'icon.svg.import', + "Resources", + "GiteaApiClient.cs" +] +def find_all_proj_files(base_path): + res = [] + for root, dirs, files in os.walk(base_path): + dirs[:] = [d for d in dirs if not d.startswith('.') and not d in ignores] + for file in files: + if file not in ignores: + res.append(os.path.join(root, file)) + return res + + +def summerizer(): + current_dir = os.path.dirname(os.path.abspath(__file__)) + + + fs = find_all_proj_files(current_dir) + res = "" + for file in fs: + with open(file) as f: + res += f"---------------------{file}-------------------------\n" + res += f.read() + res += "\n" + print(res) + +summerizer() \ No newline at end of file