From 1b5c53304a368bb4b164b9a6fabc74f969beabf0 Mon Sep 17 00:00:00 2001 From: Frode Aannevik Date: Sat, 21 May 2016 15:29:05 +0200 Subject: Fix TTP only working for one of multiple jobs The bug was that it did not handle TTBuild comments from another job Will now check all comments if they is a TTBuild for this job, and only trigger the job if we did not find a match Fixes: #82 --- .../bitbucketpullrequestbuilder/BitbucketRepository.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java index 4417d74..660ec21 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java @@ -182,12 +182,6 @@ public class BitbucketRepository { logger.log(Level.INFO, "Post comment: {0} with original content {1}", new Object[]{ content, this.client.postPullRequestComment(pullRequestId, content).getId() }); } - private boolean processTTPCommentBuildTags(String content, String buildKey) { - if (!this.isTTPCommentBuildTags(content)) return true; - logger.log(Level.INFO, "Processing ttp with build comment: {0}", content); - return !this.hasMyBuildTagInTTPComment(content, buildKey); - } - private boolean isTTPComment(String content) { return content.toLowerCase().contains(BUILD_REQUEST_MARKER.toLowerCase()); } @@ -241,6 +235,7 @@ public class BitbucketRepository { boolean rebuildCommentAvailable = false; if (comments != null) { Collection filteredComments = this.filterPullRequestComments(comments); + boolean hasMyBuildTag = false; for (Pullrequest.Comment comment : filteredComments) { String content = comment.getContent(); if (this.isTTPComment(content)) { @@ -249,10 +244,11 @@ public class BitbucketRepository { "Rebuild comment available for commit {0} and comment #{1}", new Object[]{ sourceCommit, comment.getId() } ); - } - rebuildCommentAvailable &= this.processTTPCommentBuildTags(content, buildKeyPart); - if (!rebuildCommentAvailable) break; + } + if (isTTPCommentBuildTags(content)) + hasMyBuildTag |= this.hasMyBuildTagInTTPComment(content, buildKeyPart); } + rebuildCommentAvailable &= !hasMyBuildTag; } if (rebuildCommentAvailable) this.postBuildTagInTTPComment(id, "TTP build flag", buildKeyPart); -- cgit v1.2.3