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

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


The following commit(s) were added to refs/heads/ignite-10930 by this push:
     new 62c999b  IGNITE-10930: PR-less contributions: tickets reports shown ok
62c999b is described below

commit 62c999b04ed9aa552c1fb036a190c49188b55aff
Author: Dmitriy Pavlov <[email protected]>
AuthorDate: Tue Jan 15 18:07:15 2019 +0300

    IGNITE-10930: PR-less contributions: tickets reports shown ok
---
 .../tcbot/visa/TcBotTriggerAndSignOffService.java  | 27 +++++++++++++++++-----
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
index 738f605..7c99b59 100644
--- 
a/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
+++ 
b/ignite-tc-helper-web/src/main/java/org/apache/ignite/ci/tcbot/visa/TcBotTriggerAndSignOffService.java
@@ -482,17 +482,24 @@ public class TcBotTriggerAndSignOffService {
 
     @Nonnull private List<BuildRefCompacted> findBuildsForPr(String suiteId, 
String prId,
         IGitHubConnIgnited ghConn, ITeamcityIgnited srv) {
-        List<BuildRefCompacted> buildHist = srv.getAllBuildsCompacted(suiteId, 
branchForTcA(prId));
+
+        List<BuildRefCompacted> buildHist = srv.getAllBuildsCompacted(suiteId, 
branchForTcDefault(prId, srv));
 
         if (!buildHist.isEmpty())
             return buildHist;
 
+        Integer prNum = Integer.valueOf(prId);
+        if (prNum < 0) {
+            return buildHist; // Don't iterate for other options if PR ID is 
absent
+        }
+
+
         buildHist = srv.getAllBuildsCompacted(suiteId, branchForTcB(prId));
 
         if (!buildHist.isEmpty())
             return buildHist;
 
-        PullRequest pr = ghConn.getPullRequest(Integer.valueOf(prId));
+        PullRequest pr = ghConn.getPullRequest(prNum);
 
         if (pr != null) {
             GitHubBranch head = pr.head();
@@ -510,11 +517,19 @@ public class TcBotTriggerAndSignOffService {
         return Collections.emptyList();
     }
 
-    String branchForTcA(String prId) {
+    private String branchForTcDefault(String prId, ITeamcityIgnited srv) {
+        Integer prNum = Integer.valueOf(prId);
+        if (prNum < 0)
+            return srv.gitBranchPrefix() + (-prNum); // Checking 
"ignite-10930" builds only
+
+        return branchForTcA(prId);
+    }
+
+    private String branchForTcA(String prId) {
         return "pull/" + prId + "/head";
     }
 
-    String branchForTcB(String prId) {
+    private String branchForTcB(String prId) {
         return "pull/" + prId + "/merge";
     }
 
@@ -560,7 +575,7 @@ public class TcBotTriggerAndSignOffService {
         for (String btId : compositeBuildTypeIds) {
             List<BuildRefCompacted> forTests = findBuildsForPr(btId, prId, 
ghConn, teamcity);
 
-            statuses.add(forTests.isEmpty() ? new 
ContributionCheckStatus(btId, branchForTcA(prId)) :
+            statuses.add(forTests.isEmpty() ? new 
ContributionCheckStatus(btId, branchForTcDefault(prId, teamcity)) :
                 contributionStatus(srvId, btId, forTests, teamcity, prId));
         }
 
@@ -610,7 +625,7 @@ public class TcBotTriggerAndSignOffService {
             status.resolvedBranch = status.branchWithFinishedSuite;
             //todo take into account running/queued
         else
-            status.resolvedBranch = !builds.isEmpty() ? 
builds.get(0).branchName(compactor) : branchForTcA(prId);
+            status.resolvedBranch = !builds.isEmpty() ? 
builds.get(0).branchName(compactor) : branchForTcDefault(prId, teamcity);
 
         String observationsStatus = 
buildObserverProvider.get().getObservationStatus(new ContributionKey(srvId, 
status.resolvedBranch));
 

Reply via email to