Skip to content
Permalink
Browse files

[FIXED JENKINS-40836] Report default branch

- Finesse would be to actually check the @ bookmark, but this should cover 99%
  • Loading branch information...
stephenc committed Jan 5, 2017
1 parent 6d67081 commit 8e810440813594a8e4f75f4db9d095c5595a0b76
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/main/java/hudson/plugins/mercurial/MercurialSCMSource.java
@@ -11,6 +11,7 @@
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.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.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 long lastModified() {
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());
}

0 comments on commit 8e81044

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