Skip to content

Commit

Permalink
[TH2-5132] Refactored RepositoryWatcherService
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Smirnov-Exactpro committed Nov 27, 2023
1 parent 061349f commit 0c93c64
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -55,7 +56,7 @@ public class RepositoryWatcherService {

private final KubernetesClient kubeClient = new KubernetesClientBuilder().build();

private int prevBranchCount;
private Set<String> prevBranches = Collections.emptySet();

private final String namespacePrefix;

Expand All @@ -77,14 +78,13 @@ private void scheduledJob() {
LOGGER.debug("fetching changes from git");
GitterContext ctx = GitterContext.getContext(config);
Map<String, String> 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);
}
Expand Down

0 comments on commit 0c93c64

Please sign in to comment.