diff --git a/src/main/java/com/exactpro/th2/inframgr/repository/RepositoryWatcherService.java b/src/main/java/com/exactpro/th2/inframgr/repository/RepositoryWatcherService.java index 44c7c7f..e027888 100644 --- a/src/main/java/com/exactpro/th2/inframgr/repository/RepositoryWatcherService.java +++ b/src/main/java/com/exactpro/th2/inframgr/repository/RepositoryWatcherService.java @@ -33,6 +33,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -55,7 +56,7 @@ public class RepositoryWatcherService { private final KubernetesClient kubeClient = new KubernetesClientBuilder().build(); - private int prevBranchCount; + private Set prevBranches = Collections.emptySet(); private final String namespacePrefix; @@ -77,14 +78,13 @@ private void scheduledJob() { LOGGER.debug("fetching changes from git"); GitterContext ctx = GitterContext.getContext(config); Map commits = ctx.getAllBranchesCommits(); - LOGGER.info("Fetched branches: {}, current/previous branch count: {}/{}", - commits.keySet(), commits.size(), prevBranchCount); - if (prevBranchCount > commits.size()) { + if (!prevBranches.equals(commits.keySet())) { + LOGGER.info("Fetched branches: {}, previous branches: {}", commits.keySet(), prevBranches); removeExtinctedNamespaces(commits.keySet()); } else { notifyAboutExtinctedNamespaces(commits.keySet()); } - prevBranchCount = commits.size(); + prevBranches = commits.keySet(); if (commitHistory.isEmpty()) { doInitialSynchronization(commits); }