From 07f725ac284ba781dc76d5d219ef1e799af9e291 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Fri, 15 Apr 2022 19:41:47 +0200 Subject: [PATCH] Removed unnecessary duplicate feature --- .../composition/GitProviderModuleDefault.kt | 2 -- .../java/taggy/provider/git/GitServicePush.kt | 21 ------------ .../taggy/provider/git/GitServicePushTest.kt | 33 ------------------- 3 files changed, 56 deletions(-) delete mode 100644 provider-git/src/main/java/taggy/provider/git/GitServicePush.kt delete mode 100644 provider-git/src/test/java/taggy/provider/git/GitServicePushTest.kt diff --git a/app/src/main/java/taggy/composition/GitProviderModuleDefault.kt b/app/src/main/java/taggy/composition/GitProviderModuleDefault.kt index 221366f..8bb9770 100644 --- a/app/src/main/java/taggy/composition/GitProviderModuleDefault.kt +++ b/app/src/main/java/taggy/composition/GitProviderModuleDefault.kt @@ -17,8 +17,6 @@ class GitProviderModuleDefault( var service: GitService service = GitServiceDefault(console, getConsoleAdapter()) service = GitServiceFetch(service, console) - if (arguments.push) - service = GitServicePush(service) if (arguments.force) service = GitServiceForce(service) service = GitServiceLogging(service, log.getLogger()) diff --git a/provider-git/src/main/java/taggy/provider/git/GitServicePush.kt b/provider-git/src/main/java/taggy/provider/git/GitServicePush.kt deleted file mode 100644 index 4e78652..0000000 --- a/provider-git/src/main/java/taggy/provider/git/GitServicePush.kt +++ /dev/null @@ -1,21 +0,0 @@ -package taggy.provider.git - -class GitServicePush( - private val source: GitService -) : GitService by source { - - override fun createTag(tag: Tag): Result { - return source.createTag(tag) - .mapCatching { pushTag(tag).getOrThrow() } - } - - private fun pushTag(tag: Tag): Result { - val remotes = getRemotes().getOrDefault(emptyList()) - val results = mutableListOf>() - for (remote in remotes) { - results += pushTag(remote, tag) - } - return results.firstOrNull { it.isFailure } ?: Result.success(Unit) - } - -} \ No newline at end of file diff --git a/provider-git/src/test/java/taggy/provider/git/GitServicePushTest.kt b/provider-git/src/test/java/taggy/provider/git/GitServicePushTest.kt deleted file mode 100644 index de7e5eb..0000000 --- a/provider-git/src/test/java/taggy/provider/git/GitServicePushTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -package taggy.provider.git - -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import org.mockito.Mock -import org.mockito.MockitoAnnotations -import org.mockito.kotlin.whenever -import kotlin.test.expect - -internal class GitServicePushTest { - - private lateinit var service: GitServicePush - private lateinit var remote: Remote - - @Mock - lateinit var source: GitService - - @BeforeEach - fun setUp() { - MockitoAnnotations.openMocks(this).close() - service = GitServicePush(source) - remote = Remote("barfoo") - whenever(source.getRemotes()).thenReturn(Result.success(listOf(remote))) - } - - @Test - fun createTag() { - val tag = Tag("foo") - whenever(source.pushTag(remote, tag)).thenReturn(Result.success(Unit)) - expect(Result.success(Unit)) { service.createTag(tag) } - } - -} \ No newline at end of file