diff options
author | Guillaume Jambet <guillaume.jambet@sonarsource.com> | 2018-02-22 18:44:57 +0100 |
---|---|---|
committer | Guillaume Jambet <guillaume.jambet@gmail.com> | 2018-03-01 15:21:05 +0100 |
commit | fe6b80b7f3f7d8903ec98cbc15684dc31f25c795 (patch) | |
tree | 498ef68cbecda5ec9cb088fcfac0bb6306fff22a /server | |
parent | 8c482aef46e1d9f3f6a1b3917d5722e1e6a5deec (diff) | |
download | sonarqube-fe6b80b7f3f7d8903ec98cbc15684dc31f25c795.tar.gz sonarqube-fe6b80b7f3f7d8903ec98cbc15684dc31f25c795.zip |
SONAR-10344 fix QualityGateChange on Branch analysis.
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-server/src/main/java/org/sonar/server/webhook/WebHooksImpl.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/webhook/WebHooksImpl.java b/server/sonar-server/src/main/java/org/sonar/server/webhook/WebHooksImpl.java index a5497710144..5036e81a92c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/webhook/WebHooksImpl.java +++ b/server/sonar-server/src/main/java/org/sonar/server/webhook/WebHooksImpl.java @@ -61,12 +61,19 @@ public class WebHooksImpl implements WebHooks { private Stream<WebhookDto> readWebHooksFrom(String projectUuid) { try (DbSession dbSession = dbClient.openSession(false)) { - Optional<ComponentDto> componentDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, projectUuid).orNull()); - ComponentDto projectDto = checkStateWithOptional(componentDto, "the requested project '%s' was not found", projectUuid); + + Optional<ComponentDto> optionalComponentDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, projectUuid).orNull()); + ComponentDto componentDto = checkStateWithOptional(optionalComponentDto, "the requested project '%s' was not found", projectUuid); + + if (componentDto.getMainBranchProjectUuid() != null && !componentDto.uuid().equals(componentDto.getMainBranchProjectUuid())) { + Optional<ComponentDto> mainBranchComponentDto = ofNullable(dbClient.componentDao().selectByUuid(dbSession, componentDto.getMainBranchProjectUuid()).orNull()); + componentDto = checkStateWithOptional(mainBranchComponentDto, "the requested project '%s' was not found", projectUuid); + } + WebhookDao dao = dbClient.webhookDao(); return Stream.concat( - dao.selectByProject(dbSession, projectDto).stream(), - dao.selectByOrganizationUuid(dbSession, projectDto.getOrganizationUuid()).stream()); + dao.selectByProject(dbSession, componentDto).stream(), + dao.selectByOrganizationUuid(dbSession, componentDto.getOrganizationUuid()).stream()); } } |