From f6bd59589d249c5bd630f24b3a2539ac2a6899ac Mon Sep 17 00:00:00 2001 From: Coen van den Munckhof Date: Mon, 3 Jun 2024 13:05:48 +0200 Subject: [PATCH] Implement --- docs_new/Tags.md | 6 ------ .../Model/ActionMenuGenerationContext.cs | 3 +++ .../Model/InitialialFunctions.cs | 9 +++++++++ src/RepoM.Api/Resources/RepositoryActionsV2.yaml | 5 ----- src/RepoM.Api/Resources/TagsV2.yaml | 5 ----- .../ScribanActionMenuTests.cs | 12 ------------ 6 files changed, 12 insertions(+), 28 deletions(-) create mode 100644 src/RepoM.ActionMenu.Core/Model/InitialialFunctions.cs diff --git a/docs_new/Tags.md b/docs_new/Tags.md index 8670edf6..3a821acc 100644 --- a/docs_new/Tags.md +++ b/docs_new/Tags.md @@ -19,12 +19,6 @@ The following `TagsV2.yaml` file defines three different tags (work, private, gi context: - type: evaluate-script@1 content: |- - # at this moment, you must leave this function intact - # todo, make sure this is not required anymore. - func translate(input) - ret input - end - func remotes_contain_inner(remotes, url_part) urls = remotes | array.map "url" filtered = array.filter(urls, do diff --git a/src/RepoM.ActionMenu.Core/Model/ActionMenuGenerationContext.cs b/src/RepoM.ActionMenu.Core/Model/ActionMenuGenerationContext.cs index f385ab32..c42ee95c 100644 --- a/src/RepoM.ActionMenu.Core/Model/ActionMenuGenerationContext.cs +++ b/src/RepoM.ActionMenu.Core/Model/ActionMenuGenerationContext.cs @@ -15,6 +15,7 @@ namespace RepoM.ActionMenu.Core.Model; using RepoM.ActionMenu.Interface.YamlModel; using RepoM.ActionMenu.Interface.YamlModel.ActionMenus; using Scriban; +using Scriban.Runtime; using FileFunctions = RepoM.ActionMenu.Core.ActionMenu.Context.FileFunctions; using IRepository = RepoM.Core.Plugin.Repository.IRepository; using RepositoryFunctions = RepoM.ActionMenu.Core.ActionMenu.Context.RepositoryFunctions; @@ -131,6 +132,8 @@ private static RepoMScriptObject CreateAndInitRepoMScriptObject(IRepository repo { var scriptObj = new RepoMScriptObject(); + scriptObj.Import(typeof(InitialFunctions)); + scriptObj.SetValue("file", new FileFunctions(), true); scriptObj.SetValue("repository", new RepositoryFunctions(repository), true); diff --git a/src/RepoM.ActionMenu.Core/Model/InitialialFunctions.cs b/src/RepoM.ActionMenu.Core/Model/InitialialFunctions.cs new file mode 100644 index 00000000..2196cf0a --- /dev/null +++ b/src/RepoM.ActionMenu.Core/Model/InitialialFunctions.cs @@ -0,0 +1,9 @@ +namespace RepoM.ActionMenu.Core.Model; + +internal static class InitialFunctions +{ + public static string? Translate(string? input) + { + return input; + } +} \ No newline at end of file diff --git a/src/RepoM.Api/Resources/RepositoryActionsV2.yaml b/src/RepoM.Api/Resources/RepositoryActionsV2.yaml index 3c3915b2..f3890467 100644 --- a/src/RepoM.Api/Resources/RepositoryActionsV2.yaml +++ b/src/RepoM.Api/Resources/RepositoryActionsV2.yaml @@ -1,11 +1,6 @@ context: - type: evaluate-script@1 content: |- - # at this moment, you must leave this function intact - func translate(input) - ret input - end - func is_null(input) ret input == null end diff --git a/src/RepoM.Api/Resources/TagsV2.yaml b/src/RepoM.Api/Resources/TagsV2.yaml index 08ca669c..9570cc93 100644 --- a/src/RepoM.Api/Resources/TagsV2.yaml +++ b/src/RepoM.Api/Resources/TagsV2.yaml @@ -1,11 +1,6 @@ context: - type: evaluate-script@1 content: |- - # at this moment, you must leave this function intact - func translate(input) - ret input - end - func remotes_contain_inner(remotes, url_part) urls = remotes | array.map "url" filtered = array.filter(urls, do diff --git a/tests/RepoM.ActionMenu.Core.Tests/ScribanActionMenuTests.cs b/tests/RepoM.ActionMenu.Core.Tests/ScribanActionMenuTests.cs index 28b12bca..a4825020 100644 --- a/tests/RepoM.ActionMenu.Core.Tests/ScribanActionMenuTests.cs +++ b/tests/RepoM.ActionMenu.Core.Tests/ScribanActionMenuTests.cs @@ -51,12 +51,6 @@ public class ScribanActionMenuTests private const string TAGS = """ context: - - type: evaluate-script@1 - content: |- - func translate(input) - ret 'translate says:' + input; - end - - name: coenm - name1: coenm1 @@ -123,12 +117,6 @@ func sonar_url(project_id) private const string ACTION_MENU = """ context: - - type: evaluate-script@1 - content: |- - func translate(input) - ret 'translate says:' + input; - end - - name: coenm - name1: coenm1