From 8f8db80472121d6220b3ad9144746232acb45cb3 Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Tue, 28 Jan 2025 09:09:31 +0100 Subject: [PATCH] Implement branch provider to prevent errors The review plugin does not explicitly check, if the branch provider is supported in events. It only checks, whether the repository supports branches per se. Therefor, if a tag is created from the ui, an internal server error is thrown. We prevent this by implementing a simple branch provider here, too. --- gradle/wrapper/changelog/branch_provider.yaml | 2 ++ .../sonia/scm/repository/spi/GitTagCommand.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 gradle/wrapper/changelog/branch_provider.yaml diff --git a/gradle/wrapper/changelog/branch_provider.yaml b/gradle/wrapper/changelog/branch_provider.yaml new file mode 100644 index 0000000000..7f2ebf8e82 --- /dev/null +++ b/gradle/wrapper/changelog/branch_provider.yaml @@ -0,0 +1,2 @@ +- type: fixed + description: Internal server error when creating tags in combination with some plugins diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitTagCommand.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitTagCommand.java index aff083c6ea..a5507c7073 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitTagCommand.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/spi/GitTagCommand.java @@ -41,6 +41,7 @@ import sonia.scm.repository.PreReceiveRepositoryHookEvent; import sonia.scm.repository.RepositoryHookEvent; import sonia.scm.repository.RepositoryHookType; import sonia.scm.repository.Tag; +import sonia.scm.repository.api.HookBranchProvider; import sonia.scm.repository.api.HookChangesetProvider; import sonia.scm.repository.api.HookContext; import sonia.scm.repository.api.HookContextFactory; @@ -220,6 +221,21 @@ public class GitTagCommand extends AbstractGitCommand implements TagCommand { }; } + @Override + public HookBranchProvider getBranchProvider() { + return new HookBranchProvider() { + @Override + public List getCreatedOrModified() { + return List.of(); + } + + @Override + public List getDeletedOrClosed() { + return List.of(); + } + }; + } + @Override public HookChangesetProvider getChangesetProvider() { Collection receiveCommands = new ArrayList<>();