Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ public String getRemoteName() {
* @param branchName
* @return true if branchName is excluded or is not included
*/
private boolean isExcluded(String branchName) {
boolean isExcluded(String branchName) {
return !Pattern.matches(getPattern(getIncludes()), branchName)
|| Pattern.matches(getPattern(getExcludes()), branchName);
}
Expand All @@ -652,7 +652,7 @@ private String getPattern(String branches) {
for (String wildcard : branches.split(" ")) {
StringBuilder quotedBranch = new StringBuilder();
for (String branch : wildcard.split("\\*")) {
if (wildcard.startsWith("*") || quotedBranches.length() > 0) {
if (wildcard.startsWith("*") || quotedBranch.length() > 0) {
quotedBranch.append(".*");
}
quotedBranch.append(Pattern.quote(branch));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.cloudbees.jenkins.plugins.bitbucket;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;

public class BitbucketSCMSourceTest {

public BitbucketSCMSource bitbucketSCMSource;

@Before
public void setUp() throws Exception {
bitbucketSCMSource = new BitbucketSCMSource("1", "owner", "repo");
}

@Test
public void shouldAllowExclusionsAtStartOfBranchName() throws Exception {
String includes = "master branch-*";
bitbucketSCMSource.setIncludes(includes);
assertFalse("Should not exclude branch-* at start of name", bitbucketSCMSource.isExcluded("branch-1.0.0"));
assertTrue("Should exclude branch in the middle of the branch name", bitbucketSCMSource.isExcluded("FOO_branch-1.0.0"));
}
}