From f2bd5247ae7ddf5df19f3ead903509db80758760 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Tue, 17 Jan 2023 00:36:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=83=D0=B2=D0=B5=D0=B4=D0=BE=D0=BC?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B1=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20MR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MergeRequestsServiceImpl.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java index 5d2834b..602685d 100644 --- a/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java +++ b/bot-core/src/main/java/dev/struchkov/bot/gitlab/core/service/impl/MergeRequestsServiceImpl.java @@ -156,28 +156,26 @@ public class MergeRequestsServiceImpl implements MergeRequestsService { mergeRequest.setUserAssignee(assigneeChanged.getNewStatus(oldMergeRequest.isUserAssignee())); mergeRequest.setUserReviewer(reviewerChanged.getNewStatus(oldMergeRequest.isUserReviewer())); - final boolean isChangedMr = !oldMergeRequest.getUpdatedDate().equals(mergeRequest.getUpdatedDate()) - || oldMergeRequest.isConflict() != mergeRequest.isConflict(); + final boolean isChangedMr = !oldMergeRequest.getUpdatedDate().equals(mergeRequest.getUpdatedDate()) || oldMergeRequest.isConflict() != mergeRequest.isConflict(); final boolean isChangedLinkedEntity = reviewerChanged.isChanged() || assigneeChanged.isChanged(); if (isChangedMr || isChangedLinkedEntity) { - final MergeRequest savedMergeRequest = repository.save(mergeRequest); if (oldMergeRequest.isNotification()) { final Project project = projectService.getByIdOrThrow(mergeRequest.getProjectId()); if (isChangedMr) { - notifyAboutStatus(oldMergeRequest, savedMergeRequest, project); - notifyAboutConflict(oldMergeRequest, savedMergeRequest, project); - notifyAboutUpdate(oldMergeRequest, savedMergeRequest, project); + notifyAboutStatus(oldMergeRequest, mergeRequest, project); + notifyAboutConflict(oldMergeRequest, mergeRequest, project); + notifyAboutUpdate(oldMergeRequest, mergeRequest, project); } if (isChangedLinkedEntity) { - notifyReviewer(reviewerChanged, savedMergeRequest, project); - notifyAssignee(assigneeChanged, savedMergeRequest, project); + notifyReviewer(reviewerChanged, mergeRequest, project); + notifyAssignee(assigneeChanged, mergeRequest, project); } } - return savedMergeRequest; + return repository.save(mergeRequest); } return oldMergeRequest; @@ -261,8 +259,8 @@ public class MergeRequestsServiceImpl implements MergeRequestsService { if ( !botUserGitlabId.equals(mergeRequest.getAuthor().getId()) // Автор MR не пользователь приложения - && !oldMergeRequest.getDateLastCommit().equals(mergeRequest.getDateLastCommit()) // Изменилась дата последнего коммита - && !mergeRequest.isConflict() // MR не находится в состоянии конфликта + && !oldMergeRequest.getDateLastCommit().equals(mergeRequest.getDateLastCommit()) // Изменилась дата последнего коммита + && !mergeRequest.isConflict() // MR не находится в состоянии конфликта ) { long allTask = 0; @@ -304,8 +302,8 @@ public class MergeRequestsServiceImpl implements MergeRequestsService { final Long gitlabUserId = personInformation.getId(); if ( !oldMergeRequest.isConflict() // У старого MR не было конфликта - && mergeRequest.isConflict() // А у нового есть - && gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // и MR создан пользователем бота + && mergeRequest.isConflict() // А у нового есть + && gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // и MR создан пользователем бота ) { notifyService.send( ConflictPrNotify.builder() @@ -324,7 +322,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService { final Long gitlabUserId = personInformation.getId(); if ( !oldStatus.equals(newStatus) // статус изменился - && gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // создатель MR является пользователем бота + && gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // создатель MR является пользователем бота ) { notifyService.send( StatusPrNotify.builder()