You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dp...@apache.org on 2019/06/09 12:00:22 UTC

[ignite-teamcity-bot] branch master updated: Removed odd text from email if there was no changes in build

This is an automated email from the ASF dual-hosted git repository.

dpavlov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git


The following commit(s) were added to refs/heads/master by this push:
     new 6a54abd  Removed odd text from email if there was no changes in build
6a54abd is described below

commit 6a54abdaf18af77201c801158b9c15b66c8a06e0
Author: Dmitriy Pavlov <dp...@apache.org>
AuthorDate: Sun Jun 9 15:00:15 2019 +0300

    Removed odd text from email if there was no changes in build
---
 .../ignite/ci/tcbot/conf/NotificationsConfig.java  |  3 +-
 .../apache/ignite/ci/tcbot/issue/Notification.java | 53 ++++++++++++++++------
 2 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationsConfig.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationsConfig.java
index 32cd235..31b6fa3 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationsConfig.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/conf/NotificationsConfig.java
@@ -43,7 +43,7 @@ public class NotificationsConfig {
     /** Channels to send notifications to. */
     private List<NotificationChannel> channels = new ArrayList<>();
 
-    @NotNull public static NotificationsConfig backwardConfig() {
+    @NotNull static NotificationsConfig backwardConfig() {
         Properties cfgProps = HelperConfig.loadEmailSettings();
 
         NotificationsConfig cfg = new NotificationsConfig();
@@ -61,6 +61,7 @@ public class NotificationsConfig {
             ch.subscribe(TcServerConfig.DEFAULT_TRACKED_BRANCH_NAME);
             cfg.channels.add(ch);
         }
+
         return cfg;
     }
 
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/issue/Notification.java b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/issue/Notification.java
index 2818799..21ebb72 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/issue/Notification.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/issue/Notification.java
@@ -17,15 +17,11 @@
 
 package org.apache.ignite.ci.tcbot.issue;
 
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
 import org.apache.ignite.ci.issue.Issue;
-import org.apache.ignite.tcbot.common.util.TimeUtil;
 import org.apache.ignite.ci.web.model.Version;
+import org.apache.ignite.tcbot.common.util.TimeUtil;
+
+import java.util.*;
 
 import static org.apache.ignite.ci.web.model.Version.GITHUB_REF;
 
@@ -82,6 +78,11 @@ public class Notification {
         return sb.toString();
     }
 
+    public boolean involvesChange() {
+        return buildIdToIssue.values().stream().flatMap(Collection::stream)
+                .anyMatch(issue -> !issue.changes.isEmpty());
+    }
+
     public String toPlainText() {
         StringBuilder sb = new StringBuilder();
 
@@ -107,17 +108,39 @@ public class Notification {
     }
 
     private String messageHeaderHtml() {
-        return "Hi Igniters,<br><br>" +
-            " " + DETECTED_ISSUE + "<br><br>" +
-            " " + IF_YOUR_CHANGES + "<br>" +
-            " " + YOUR_ACTION + "<br><br>";
+        StringBuilder res = new StringBuilder();
+        res.append("Hi Igniters,<br><br>");
+        res.append(" ");
+        res.append(DETECTED_ISSUE);
+        res.append("<br><br>");
+
+        if (involvesChange()) {
+            res.append(" ");
+            res.append(IF_YOUR_CHANGES);
+            res.append("<br>");
+            res.append(" ");
+            res.append(YOUR_ACTION);
+            res.append("<br><br>");
+        }
+        return res.toString();
     }
 
     private String messageHeaderPlainText() {
-        return "Hi Igniters,\n\n" +
-            " " + DETECTED_ISSUE + "\n\n" +
-            " " + IF_YOUR_CHANGES + "\n" +
-            " " + YOUR_ACTION + "\n\n";
+        StringBuilder res = new StringBuilder();
+        res.append("Hi Igniters,\n\n");
+        res.append(" ");
+        res.append(DETECTED_ISSUE);
+        res.append("\n\n");
+        if (involvesChange()) {
+            res.append(" ");
+            res.append(IF_YOUR_CHANGES);
+            res.append("\n");
+            res.append(" ");
+            res.append(YOUR_ACTION);
+            res.append("\n\n");
+        }
+
+        return res.toString();
     }
 
     private String messageTailPlainText() {