Permalink
Browse files

[JENKINS-14026] DefaultBuildChooser should handle smartly branches wi…

…th /

When encountering a single branch containing a '/', it is either a qualified branch or a branch containing a '/'
In the first case, the branch should start with the name of a declared remote
Otherwise, we fall back to unqualified behaviour, and we try to match the branch name as if it was */BRANCH
  • Loading branch information...
Vlatombe committed Jan 27, 2014
1 parent dcae493 commit ea5cad7e2759d0c9f5ed723fe590f982b0bb818d
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 ea5cad7

Please sign in to comment.