Skip to content
Permalink
Browse files

Merge pull request #37 from jenkinsci/jenkins-38987-followup

[JENKINS-38987 Follow-up] Expose the SCM API pronoun information
  • Loading branch information...
stephenc committed Oct 18, 2016
2 parents 7d126df + 6c956be commit 3f1a413631dcfd122fc6c87867052eca0855c704
@@ -79,12 +79,12 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>scm-api</artifactId>
<version>1.3</version>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>branch-api</artifactId>
<version>1.11</version>
<version>1.12-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -218,7 +218,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>2.1.4</version>
<version>2.1.6</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -25,13 +25,16 @@
package org.jenkinsci.plugins.workflow.multibranch;

import hudson.Extension;
import hudson.model.AbstractItem;
import hudson.model.Item;
import hudson.model.JobPropertyDescriptor;
import hudson.security.ACL;
import hudson.security.Permission;
import hudson.util.AlternativeUiTextProvider;
import javax.annotation.Nonnull;
import jenkins.branch.Branch;
import org.acegisecurity.Authentication;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowJobProperty;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
@@ -82,4 +85,20 @@ synchronized void setBranch(@Nonnull Branch branch) {

}

@Extension
public static class AlternativeUiTextProviderImpl extends AlternativeUiTextProvider {

@Override
public <T> String getText(Message<T> text, T context) {
if (text == AbstractItem.PRONOUN && context instanceof WorkflowJob) {
WorkflowJob job = (WorkflowJob) context;
BranchJobProperty property = job.getProperty(BranchJobProperty.class);
if (property != null) {
return property.getBranch().getHead().getPronoun();
}
}
return null;
}
}

}
@@ -48,6 +48,7 @@
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.SCMRevisionAction;
import jenkins.scm.api.SCMSource;
import jenkins.scm.api.SCMSourceDescriptor;
import jenkins.scm.impl.subversion.SubversionSCMSource;
import static org.hamcrest.Matchers.*;

@@ -255,7 +256,7 @@ public WarySource(String id, String remote, String credentialsId, String include
return fetch(new SCMHead("master"), listener);
}
}
@Override public Descriptor<SCMSource> getDescriptor() {
@Override public SCMSourceDescriptor getDescriptor() {
return Jenkins.getInstance().getDescriptorByType(GitSCMSource.DescriptorImpl.class);
}
}

0 comments on commit 3f1a413

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