Skip to content
Permalink
Browse files

Merge pull request #195 from Vlatombe/JENKINS-14026

[JENKINS-14026] DefaultBuildChooser should handle smartly branches with /
  • Loading branch information...
ndeloof committed Jan 27, 2014
2 parents dcae493 + ea5cad7 commit b22146d14997edaaf9bd95a054c65b623606d379
Showing with 21 additions and 3 deletions.
  1. +21 −3 src/main/java/hudson/plugins/git/util/DefaultBuildChooser.java
@@ -87,9 +87,27 @@ public DefaultBuildChooser() {
revisions.addAll(getHeadRevision(isPollCall, fqbn, git, listener, data));
}
} else {
// singleBranch contains a '/', so is in most case a fully qualified branch
// doesn't seem we can distinguish unqualified branch with '/' in name, so expect users to fully qualify
revisions.addAll(getHeadRevision(isPollCall, singleBranch, git, listener, data));
// either the branch is qualified (first part should match a valid remote)
// or it is still unqualified, but the branch name contains a '/'
List<String> possibleQualifiedBranches = new ArrayList<String>();
boolean singleBranchIsQualified = false;
for (RemoteConfig config : gitSCM.getRepositories()) {
String repository = config.getName();
if (singleBranch.startsWith(repository + "/")) {
singleBranchIsQualified = true;
break;
}
String fqbn = repository + "/" + singleBranch;
verbose(listener, "Qualifying {0} as a branch in repository {1} -> {2}", singleBranch, repository, fqbn);
possibleQualifiedBranches.add(fqbn);
}
if (singleBranchIsQualified) {
revisions.addAll(getHeadRevision(isPollCall, singleBranch, git, listener, data));
} else {
for (String fqbn : possibleQualifiedBranches) {
revisions.addAll(getHeadRevision(isPollCall, fqbn, git, listener, data));
}
}
}

return revisions;

0 comments on commit b22146d

Please sign in to comment.
You can’t perform that action at this time.