From 2a50e355870b9c028b012edaa5267aa6a7b6d612 Mon Sep 17 00:00:00 2001 From: Mat Mannion Date: Sat, 2 Mar 2019 09:38:35 +0000 Subject: [PATCH] Trigger repository mirroring on more events --- .../bitbucket/hook/MirrorRepositoryHook.java | 16 +++++++++++----- .../bitbucket/hook/MirrorRepositoryHookTest.java | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/englishtown/bitbucket/hook/MirrorRepositoryHook.java b/src/main/java/com/englishtown/bitbucket/hook/MirrorRepositoryHook.java index 5f0dbd9..f4075d1 100644 --- a/src/main/java/com/englishtown/bitbucket/hook/MirrorRepositoryHook.java +++ b/src/main/java/com/englishtown/bitbucket/hook/MirrorRepositoryHook.java @@ -1,9 +1,6 @@ package com.englishtown.bitbucket.hook; -import com.atlassian.bitbucket.hook.repository.PostRepositoryHook; -import com.atlassian.bitbucket.hook.repository.PostRepositoryHookContext; -import com.atlassian.bitbucket.hook.repository.RepositoryHookRequest; -import com.atlassian.bitbucket.hook.repository.StandardRepositoryHookTrigger; +import com.atlassian.bitbucket.hook.repository.*; import com.atlassian.bitbucket.i18n.I18nService; import com.atlassian.bitbucket.repository.Repository; import com.atlassian.bitbucket.repository.RepositoryService; @@ -21,6 +18,7 @@ import com.atlassian.bitbucket.setting.SettingsValidator; import com.atlassian.sal.api.pluginsettings.PluginSettings; import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; import com.google.common.base.Strings; +import com.google.common.collect.ImmutableSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,6 +57,14 @@ public class MirrorRepositoryHook implements PostRepositoryHook TRIGGERS_TO_IGNORE = + ImmutableSet.of( + StandardRepositoryHookTrigger.UNKNOWN + ); + private final ScmService scmService; private final I18nService i18nService; private final ScheduledExecutorService executor; @@ -107,7 +113,7 @@ public class MirrorRepositoryHook implements PostRepositoryHook mirrorSettings = getMirrorSettings(context.getSettings()); diff --git a/src/test/java/com/englishtown/bitbucket/hook/MirrorRepositoryHookTest.java b/src/test/java/com/englishtown/bitbucket/hook/MirrorRepositoryHookTest.java index f8b0417..7c749f7 100644 --- a/src/test/java/com/englishtown/bitbucket/hook/MirrorRepositoryHookTest.java +++ b/src/test/java/com/englishtown/bitbucket/hook/MirrorRepositoryHookTest.java @@ -107,7 +107,7 @@ public class MirrorRepositoryHookTest { public void testUnwantedEventsIgnored() { Repository repo = mock(Repository.class); - hook.postUpdate(buildContext(), buildRequest(StandardRepositoryHookTrigger.BRANCH_CREATE, repo)); + hook.postUpdate(buildContext(), buildRequest(StandardRepositoryHookTrigger.UNKNOWN, repo)); verify(executor, never()).submit(ArgumentMatchers.any()); }