Skip to content
Permalink
Browse files

Merge pull request #52 from jenkinsci/jenkins-38987-follow-up

[JENKINS-38987 Follow-up] Pick up SCMxxx.getPronoun()
  • Loading branch information
stephenc committed Oct 14, 2016
2 parents 4fdf888 + ccbc3e6 commit 637eeced2a9adbd02e0ded25eb3bdfc34caa0a79
@@ -87,12 +87,12 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>1.2</version>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-folder</artifactId>
<version>5.10</version>
<version>5.14-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -116,7 +116,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.24</version>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -76,6 +76,7 @@ private Object readResolve() {
*
* @return the source.
*/
@NonNull
public SCMSource getSource() {
return source;
}
@@ -45,20 +45,6 @@
import hudson.security.ACL;
import hudson.security.Permission;
import hudson.util.PersistedList;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMHeadObserver;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMSource;
import jenkins.scm.api.SCMSourceCriteria;
import jenkins.scm.api.SCMSourceOwner;
import jenkins.scm.impl.NullSCMSource;
import net.sf.json.JSONObject;
import org.acegisecurity.Authentication;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;

import javax.servlet.ServletException;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
@@ -68,10 +54,25 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import jenkins.model.ParameterizedJobMixIn;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMHeadObserver;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMSource;
import jenkins.scm.api.SCMSourceCriteria;
import jenkins.scm.api.SCMSourceOwner;
import jenkins.scm.impl.NullSCMSource;
import jenkins.triggers.SCMTriggerItem;
import net.sf.json.JSONObject;
import org.acegisecurity.Authentication;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;

/**
* Abstract base class for multiple-branch based projects.
@@ -142,6 +143,21 @@ private synchronized void init2() {
factory.setOwner(this);
}

/**
* {@inheritDoc}
*/
@Override
public String getPronoun() {
Set<String> result = new TreeSet<>();
for (BranchSource source: sources) {
String pronoun = Util.fixEmptyAndTrim(source.getSource().getPronoun());
if (pronoun != null) {
result.add(pronoun);
}
}
return result.isEmpty() ? super.getPronoun() : StringUtils.join(result, " / ");
}

/**
* Returns the {@link BranchProjectFactory}. ˜
*
@@ -617,7 +633,7 @@ public File getLogFile() {
*/
@Override
public String getDisplayName() {
return "Branch Indexing";
return Messages.MultiBranchProject_BranchIndexing_displayName(getParent().getPronoun());
}

/**
@@ -28,9 +28,11 @@
import com.cloudbees.hudson.plugins.folder.AbstractFolderDescriptor;
import com.cloudbees.hudson.plugins.folder.computed.ChildObserver;
import com.cloudbees.hudson.plugins.folder.computed.ComputedFolder;
import com.cloudbees.hudson.plugins.folder.computed.FolderComputation;
import com.cloudbees.hudson.plugins.folder.computed.PeriodicFolderTrigger;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.Util;
import hudson.model.Descriptor;
import hudson.model.Item;
import hudson.model.ItemGroup;
@@ -46,15 +48,19 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.concurrent.Callable;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.servlet.ServletException;
import jenkins.scm.api.SCMNavigator;
import jenkins.scm.api.SCMNavigatorDescriptor;
import jenkins.scm.api.SCMSource;
import jenkins.scm.api.SCMSourceCriteria;
import jenkins.scm.api.SCMSourceObserver;
import jenkins.scm.api.SCMSourceOwner;
import org.apache.commons.lang.StringUtils;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.StaplerRequest;
@@ -115,6 +121,13 @@ protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOExceptio
projectFactories.rebuildHetero(req, req.getSubmittedForm(), ExtensionList.lookup(MultiBranchProjectFactoryDescriptor.class), "projectFactories");
}

@Nonnull
@Override
protected FolderComputation<MultiBranchProject<?, ?>> createComputation(
@CheckForNull FolderComputation<MultiBranchProject<?, ?>> previous) {
return new OrganizationScan(OrganizationFolder.this, previous);
}

@Override
protected void computeChildren(final ChildObserver<MultiBranchProject<?,?>> observer, final TaskListener listener) throws IOException, InterruptedException {
for (SCMNavigator navigator : navigators) {
@@ -210,6 +223,21 @@ public void addAttribute(String key, Object value) throws IllegalArgumentExcepti
}
}

/**
* {@inheritDoc}
*/
@Override
public String getPronoun() {
Set<String> result = new TreeSet<>();
for (SCMNavigator navigator: navigators) {
String pronoun = Util.fixEmptyAndTrim(navigator.getPronoun());
if (pronoun != null) {
result.add(pronoun);
}
}
return result.isEmpty() ? super.getPronoun() : StringUtils.join(result, " / ");
}

@Override
public List<SCMSource> getSCMSources() {
// Probably unused unless onSCMSourceUpdated implemented, but just in case:
@@ -296,4 +324,18 @@ public TopLevelItem newInstance(ItemGroup parent, String name) {

}

public static class OrganizationScan extends FolderComputation<MultiBranchProject<?, ?>> {
public OrganizationScan(OrganizationFolder folder, FolderComputation<MultiBranchProject<?, ?>> previous) {
super(folder, previous);
}

/**
* {@inheritDoc}
*/
@Override
public String getDisplayName() {
return Messages.OrganizationFolder_OrganizationScan_displayName(getParent().getPronoun());
}

}
}
@@ -36,3 +36,5 @@ RateLimitBranchProperty.duration.day=Day
RateLimitBranchProperty.duration.week=Week
RateLimitBranchProperty.duration.month=Month
RateLimitBranchProperty.duration.year=Year
MultiBranchProject.BranchIndexing.displayName=Scan {0}
OrganizationFolder.OrganizationScan.displayName=Scan {0}

0 comments on commit 637eece

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