Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #37 from jenkinsci/jenkins-38987-followup
Browse files Browse the repository at this point in the history
[JENKINS-38987 Follow-up] Expose the SCM API pronoun information
  • Loading branch information
stephenc committed Oct 18, 2016
2 parents 7d126df + 6c956be commit 3f1a413
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -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>
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) 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 3f1a413

Please sign in to comment.