Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 13, 2017
1 parent 6d67081 commit 8e81044
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/hudson/plugins/mercurial/MercurialSCMSource.java
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 8e81044

Please sign in to comment.