Skip to content

Commit

Permalink
[FIXED JENKINS-14480] handle fully qualified branch names
Browse files Browse the repository at this point in the history
backward compatible way
  • Loading branch information
ndeloof committed Jul 23, 2012
1 parent 16340b1 commit 2ee61e6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main/java/hudson/plugins/git/util/DefaultBuildChooser.java
Expand Up @@ -70,6 +70,8 @@ public Collection<Revision> getCandidateRevisions(boolean isPollCall, String sin
}
}

Collection<Revision> revisions = new ArrayList<Revision>();

// if it doesn't contain '/' then it could be either a tag or an unqualified branch
if (!singleBranch.contains("/")) {
// the 'branch' could actually be a tag:
Expand All @@ -78,15 +80,21 @@ public Collection<Revision> getCandidateRevisions(boolean isPollCall, String sin
verbose(listener, "{0} is a tag");
return getHeadRevision(isPollCall, singleBranch, git, listener, data);
}
}

Collection<Revision> revisions = new ArrayList<Revision>();
for (RemoteConfig config : gitSCM.getRepositories()) {
String repository = config.getName();
singleBranch = repository + "/" + singleBranch;
verbose(listener, "Qualifying {0} with the repository {1} a a branch", singleBranch, repository);
// <tt>BRANCH</tt> is recognized as a shorthand of <tt>*/BRANCH</tt>
// so check all remotes to fully qualify this branch spec
for (RemoteConfig config : gitSCM.getRepositories()) {
String repository = config.getName();
String fqbn = repository + "/" + singleBranch;
verbose(listener, "Qualifying {0} as a branch in repository {1} -> {2}", singleBranch, repository, fqbn);
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));
}

return revisions;
}

Expand Down

0 comments on commit 2ee61e6

Please sign in to comment.