From 8357cc482beba438df0bccce4fd4e500d67978bb Mon Sep 17 00:00:00 2001 From: Robert Jeppesen Date: Thu, 15 May 2014 07:29:35 +0200 Subject: Avoid repeating builds indefinitely after deleting the 'Build started' comment --- .../bitbucketpullrequestbuilder/BitbucketRepository.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main/java/bitbucketpullrequestbuilder') diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java index 904892e..61d3702 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java @@ -17,7 +17,8 @@ import java.util.logging.Logger; public class BitbucketRepository { private static final Logger logger = Logger.getLogger(BitbucketRepository.class.getName()); public static final String BUILD_START_MARKER = "[*BuildStarted*] %s"; - public static final String BUILD_FINISH_MARKER = "[*BuildFinished*] %s \n\n **%s** - %s"; + public static final String BUILD_FINISH_MARKER = "[*BuildFinished*] %s"; + public static final String BUILD_FINISH_SENTENCE = BUILD_FINISH_MARKER + " \n\n **%s** - %s"; public static final String BUILD_REQUEST_MARKER = "test this please"; public static final String BUILD_SUCCESS_COMMENT = ":star:SUCCESS"; @@ -87,7 +88,7 @@ public class BitbucketRepository { if (success){ message = BUILD_SUCCESS_COMMENT; } - String comment = String.format(BUILD_FINISH_MARKER, commit, message, buildUrl); + String comment = String.format(BUILD_FINISH_SENTENCE, commit, message, buildUrl); this.client.postPullRequestComment(pullRequestId, comment); } @@ -105,7 +106,8 @@ public class BitbucketRepository { String repositoryName = destination.getRepository().getRepositoryName(); String id = pullRequest.getId(); List comments = client.getPullRequestComments(owner, repositoryName, id); - String searchString = String.format(BUILD_START_MARKER, commit).toLowerCase(); + String searchStartMarker = String.format(BUILD_START_MARKER, commit).toLowerCase(); + String searchFinishMarker = String.format(BUILD_FINISH_MARKER, commit).toLowerCase(); if (comments != null) { Collections.sort(comments); @@ -116,7 +118,8 @@ public class BitbucketRepository { continue; } content = content.toLowerCase(); - if (content.contains(searchString)) { + if (content.contains(searchStartMarker) || + content.contains(searchFinishMarker)) { shouldBuild = false; break; } -- cgit v1.2.3