Skip to content
Permalink
Browse files

[FIX JENKINS-28506] restore support fo refs/heads/branch branch speci…

…fier
  • Loading branch information
ndeloof committed May 26, 2015
1 parent b71ed52 commit f63e20a7f7c3f1d347d0357e61e2612ee40a983d
Showing with 13 additions and 7 deletions.
  1. +13 −7 src/main/java/hudson/plugins/git/GitSCM.java
@@ -583,22 +583,28 @@ private PollingResult compareRemoteRevisionWithImpl(Job<?, ?> project, Launcher
for (BranchSpec branchSpec : getBranches()) {
for (Entry<String, ObjectId> entry : heads.entrySet()) {
final String head = entry.getKey();
String name;
// head is "refs/(heads|tags)/branchName
if (head.startsWith("refs/heads/")) name = remote + "/" + head.substring(11);
else if (head.startsWith("refs/tags/")) name = remote + "/" + head.substring(10);
else name = remote + "/" + head;

if (!branchSpec.matches(name, environment)) continue;
// first, check the a canonical git reference is configured
if (!branchSpec.matches(head, environment)) {

// convert head `refs/*` into shortcut notation `remote/branch`
String name = head;
if (head.startsWith("refs/heads/")) name = remote + "/" + head.substring(11);
else if (head.startsWith("refs/tags/")) name = remote + "/" + head.substring(10);
else name = remote + "/" + head;

if (!branchSpec.matches(name, environment)) continue;
}

final ObjectId sha1 = entry.getValue();
Build built = buildData.getLastBuild(sha1);
if (built != null) {
listener.getLogger().println("[poll] Latest remote head revision on " + name + " is: " + sha1.getName() + " - already built by " + built.getBuildNumber());
listener.getLogger().println("[poll] Latest remote head revision on " + head + " is: " + sha1.getName() + " - already built by " + built.getBuildNumber());
continue;
}

listener.getLogger().println("[poll] Latest remote head revision on " + name + " is: " + sha1.getName());
listener.getLogger().println("[poll] Latest remote head revision on " + head + " is: " + sha1.getName());
return BUILD_NOW;
}
}

0 comments on commit f63e20a

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