Skip to content

Commit

Permalink
[JENKINS-38987 Follow-up] Expose the SCM API pronoun information
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenc committed Oct 14, 2016
1 parent 00e1e44 commit 3457d83
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
14 changes: 7 additions & 7 deletions pom.xml
Expand Up @@ -69,7 +69,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.6</version>
<version>2.8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand All @@ -79,22 +79,22 @@ 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>
<artifactId>cloudbees-folder</artifactId>
<version>5.12</version>
<version>5.14-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.3</version>
<version>2.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down Expand Up @@ -140,7 +140,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.4</version>
<version>2.9-SNAPSHOT</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -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>
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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.class.cast(context);
BranchJobProperty property = job.getProperty(BranchJobProperty.class);
if (property != null) {
return property.getBranch().getHead().getPronoun();
}
}
return null;
}
}

}
Expand Up @@ -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.*;

Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 3457d83

Please sign in to comment.