ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpav...@apache.org
Subject [ignite-teamcity-bot] 02/02: PR apply script added; code style changes applied; version updated
Date Fri, 17 Aug 2018 15:54:05 GMT
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

commit 7f89dabfcc430c52bbe0af97b1133af6eec7840c
Author: Dmitriy Pavlov <dpavlov@apache.org>
AuthorDate: Fri Aug 17 18:52:50 2018 +0300

    PR apply script added; code style changes applied; version updated
---
 .../org/apache/ignite/ci/conf/BranchTracked.java   |  5 ++-
 .../org/apache/ignite/ci/conf/BranchesTracked.java |  8 +++--
 .../org/apache/ignite/ci/conf/PasswordEncoder.java |  9 +++--
 .../org/apache/ignite/ci/mail/EmailSender.java     |  5 ++-
 .../org/apache/ignite/ci/mail/SlackSender.java     | 38 ++++++++++------------
 .../org/apache/ignite/ci/web/model/Version.java    |  5 ++-
 scripts/apply-pull-request.bat                     | 24 ++++++++++++++
 7 files changed, 60 insertions(+), 34 deletions(-)

diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/BranchTracked.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/BranchTracked.java
index 5a9d973..7bdcc2c 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/BranchTracked.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/BranchTracked.java
@@ -22,7 +22,7 @@ import java.util.List;
 import java.util.stream.Stream;
 
 /**
- * Created by Дмитрий on 05.11.2017.
+ * One tracked branch, probably on several servers
  */
 public class BranchTracked {
     /** ID for internal REST and for */
@@ -30,6 +30,9 @@ public class BranchTracked {
 
     public List<ChainAtServerTracked> chains = new ArrayList<>();
 
+    /**
+     * @return internal identifier of the branch.
+     */
     public String getId() {
         return id;
     }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/BranchesTracked.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/BranchesTracked.java
index 4f4149f..6bf2d50 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/BranchesTracked.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/BranchesTracked.java
@@ -24,11 +24,15 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
- * Created by Дмитрий on 05.11.2017.
+ * Config file for tracked branches.
  */
 public class BranchesTracked {
-    public List<BranchTracked> branches = new ArrayList<>();
+    /** Branches. */
+    private List<BranchTracked> branches = new ArrayList<>();
 
+    /**
+     * @return list of internal identifiers of branch.
+     */
     public List<String> getIds() {
         return branches.stream().map(BranchTracked::getId).collect(Collectors.toList());
     }
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/PasswordEncoder.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/PasswordEncoder.java
index 0197248..65fcb63 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/PasswordEncoder.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/conf/PasswordEncoder.java
@@ -33,13 +33,12 @@ import static javax.xml.bind.DatatypeConverter.parseHexBinary;
 import static javax.xml.bind.DatatypeConverter.printHexBinary;
 
 /**
- * Created by Дмитрий on 05.11.2017.
+ * Encoding utility to avoid simply readable password in config.
  */
 public class PasswordEncoder {
-
-    public static final int PREF_LEN = 16;
-    public static final int POSTF_LEN = 16;
-    public static final char CHAR = 'A';
+    private static final int PREF_LEN = 16;
+    private static final int POSTF_LEN = 16;
+    private static final char CHAR = 'A';
 
     public static String decode(String encPass) {
         final String clearBlk = printHexBinary(d(parseHexBinary(encPass)));
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/mail/EmailSender.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/mail/EmailSender.java
index 5c716ab..dfb8ef8 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/mail/EmailSender.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/mail/EmailSender.java
@@ -44,7 +44,7 @@ public class EmailSender {
 
     public static void sendEmail(String to, String subject, String html, String plainText)
{
         Properties cfgProps = HelperConfig.loadEmailSettings();
-        String username = HelperConfig.getMandatoryProperty(cfgProps, HelperConfig.USERNAME,
HelperConfig. MAIL_PROPS);
+        String from = HelperConfig.getMandatoryProperty(cfgProps, HelperConfig.USERNAME,
HelperConfig. MAIL_PROPS);
         String enc = HelperConfig.getMandatoryProperty(cfgProps, HelperConfig.ENCODED_PASSWORD,
HelperConfig.MAIL_PROPS);
 
         String pwd = PasswordEncoder.decode(enc);
@@ -57,14 +57,13 @@ public class EmailSender {
         props.put("mail.smtp.port", "465");
 
         // Sender's email ID needs to be mentioned
-        String from = username;
         // Setup mail getOrCreateCreds
         // Get the default Session object.
 
         Session ses = Session.getInstance(props,
                 new Authenticator() {
                     @Override protected PasswordAuthentication getPasswordAuthentication()
{
-                        return new PasswordAuthentication(username, pwd);
+                        return new PasswordAuthentication(from, pwd);
                     }
                 });
         try {
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/mail/SlackSender.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/mail/SlackSender.java
index 5977d75..cbd3f71 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/mail/SlackSender.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/mail/SlackSender.java
@@ -28,53 +28,51 @@ import org.apache.ignite.ci.HelperConfig;
 import java.io.IOException;
 import java.util.Properties;
 
+/**
+ *
+ */
 public class SlackSender {
-    public static void main(String[] args) throws IOException {
-        String addr = "dpavlov";
-        sendMessage(addr, "hi im a bot " +
-            "<http://localhost:8080|app>");
-    }
-
-    public static boolean sendMessage(String addr, String message) throws IOException {
+    public static boolean sendMessage(String addr, String msg) throws IOException {
         Properties cfgProps = HelperConfig.loadEmailSettings();
         String authTok = HelperConfig.getMandatoryProperty(cfgProps, HelperConfig.SLACK_AUTH_TOKEN,
HelperConfig. MAIL_PROPS);
 
-        SlackSession session = SlackSessionFactory.createWebSocketSlackSession(authTok);
-        session.connect();
+        SlackSession ses = SlackSessionFactory.createWebSocketSlackSession(authTok);
+
+        ses.connect();
 
         try {
             if(addr.startsWith("#")) {
-                String channel = addr.substring(1);
+                String ch = addr.substring(1);
 
-                SlackChannel slackChannel = session.findChannelByName(channel);
+                SlackChannel slackCh = ses.findChannelByName(ch);
 
-                if (slackChannel == null) {
-                    System.err.println("Failed to find channel [" + addr + "]: Notification
not send [" + message + "]");
+                if (slackCh == null) {
+                    System.err.println("Failed to find channel [" + addr + "]: Notification
not send [" + msg + "]");
 
                     return false;
                 }
 
-                SlackMessageHandle<SlackMessageReply> handle = session.sendMessage(slackChannel,
message);
+                SlackMessageHandle<SlackMessageReply> handle = ses.sendMessage(slackCh,
msg);
 
-                System.out.println("Message to channel " + addr + " "  + message + "; acked:
" + handle.isAcked());
+                System.out.println("Message to channel " + addr + " "  + msg + "; acked:
" + handle.isAcked());
             }
             else {
-                SlackUser user = session.findUserByUserName(addr); //make sure bot is a member
of the user.
+                SlackUser user = ses.findUserByUserName(addr); //make sure bot is a member
of the user.
 
                 if (user == null) {
-                    System.err.println("Failed to find user [" + addr + "]: Notification
not send [" + message + "]");
+                    System.err.println("Failed to find user [" + addr + "]: Notification
not send [" + msg + "]");
 
                     return false;
                 }
 
-                SlackMessageHandle<SlackMessageReply> handle = session.sendMessageToUser(user,
message, null);
+                SlackMessageHandle<SlackMessageReply> handle = ses.sendMessageToUser(user,
msg, null);
 
-                System.out.println("Message to user " + addr + " "  + message + "; acked:
" + handle.isAcked());
+                System.out.println("Message to user " + addr + " "  + msg + "; acked: " +
handle.isAcked());
 
             }
         }
         finally {
-            session.disconnect();
+            ses.disconnect();
         }
 
         return true;
diff --git a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
index 7adf240..cc1fe27 100644
--- a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
+++ b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/web/model/Version.java
@@ -19,7 +19,7 @@ package org.apache.ignite.ci.web.model;
 
 @SuppressWarnings("PublicField") public class Version {
     /** TC Helper Version. */
-    public String version = "20180813";
+    public String version = "20180817";
 
     /** Ignite version. */
     public String ignVer;
@@ -28,8 +28,7 @@ package org.apache.ignite.ci.web.model;
     public String ignVerFull;
 
     /** TC Helper Source web. */
-    public String srcWebUrl = "https://github.com/dspavlov/ignite-teamcity-helper";
-
+    public String srcWebUrl = "https://github.com/ignite/ignite-teamcity-bot";
 
     public Version() {}
 }
diff --git a/scripts/apply-pull-request.bat b/scripts/apply-pull-request.bat
new file mode 100644
index 0000000..b094122
--- /dev/null
+++ b/scripts/apply-pull-request.bat
@@ -0,0 +1,24 @@
+@echo off
+set PR_BRANCH_NAME=pr%1
+set TARGET_BRANCH=master
+
+set APACHE_GIT=https://gitbox.apache.org/repos/asf/ignite-teamcity-bot.git
+set GITHUB_MIRROR=https://github.com/apache/ignite-teamcity-bot
+
+git fetch %GITHUB_MIRROR% pull/%1/head:%PR_BRANCH_NAME%
+
+rem jump to branch to show data 
+git checkout %PR_BRANCH_NAME%
+
+rem show author 
+git --no-pager show -s 
+rem removed from command --format="%%aN <%%aE>" HEAD
+
+rem show message
+echo "
+git log -1 --pretty=%%B
+echo  - Fixes #%1."
+rem removed from command --pretty=%%B
+
+git checkout %TARGET_BRANCH%
+git merge --squash %PR_BRANCH_NAME%


Mime
View raw message