[FIXED Report default branch
Finesse would be to actually check the @ bookmark, but this should cover 99%
@@ -11,6 +11,7 @@ import hudson.Extension;
import hudson.FilePath;
import hudson.Launcher;
import hudson.Util;
+import hudson.model.Action;
import hudson.model.Descriptor;
import hudson.model.Item;
import hudson.model.Node;
@@ -24,6 +25,7 @@ import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import hudson.util.VersionNumber;
import java.io.IOException;
+import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -40,6 +42,7 @@ import jenkins.scm.api.SCMSource;
import jenkins.scm.api.SCMSourceCriteria;
import jenkins.scm.api.SCMSourceDescriptor;
import jenkins.scm.api.SCMSourceOwner;
+import jenkins.scm.api.metadata.PrimaryInstanceMetadataAction;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
@@ -204,6 +207,18 @@ public final class MercurialSCMSource extends SCMSource {
return null;
}
+ @NonNull
+ @Override
+ protected List<Action> retrieveActions(@NonNull SCMHead head,
+ @edu.umd.cs.findbugs.annotations.CheckForNull SCMHeadEvent event,
+ @NonNull TaskListener listener) throws IOException, InterruptedException {
+ // TODO for Mecrurial 2.4+ check for the bookmark called @ and resolve that to determine the primary
+ if ("default".equals(head.getName())) {
+ return Collections.<Action>singletonList(new PrimaryInstanceMetadataAction());
+ }
+ return Collections.emptyList();
+ }
+
private static List<? extends StandardUsernameCredentials> availableCredentials(@CheckForNull SCMSourceOwner owner, @CheckForNull String source) {
return CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, owner, null, URIRequirementBuilder.fromUri(source).build());
}
