Skip to content

Commit

Permalink
Merge pull request #82 from jenkinsci/jenkins-38987-followup
Browse files Browse the repository at this point in the history
[JENKINS-38987 Follow-up] Provide implementations of getPronoun() for the SCMHead/Source/Navigator
  • Loading branch information
stephenc committed Oct 17, 2016
2 parents 794434f + c0557dd commit 9dbc8d7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -34,7 +34,7 @@
<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>
Expand All @@ -56,7 +56,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.22</version>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>com.coravy.hudson.plugins.github</groupId>
Expand Down
@@ -0,0 +1,25 @@
package org.jenkinsci.plugins.github_branch_source;

import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.scm.api.SCMHead;

/**
* Head corresponding to a branch.
* @since FIXME
*/
public class BranchSCMHead extends SCMHead {
/**
* {@inheritDoc}
*/
public BranchSCMHead(@NonNull String name) {
super(name);
}

/**
* {@inheritDoc}
*/
@Override
public String getPronoun() {
return Messages.BranchSCMHead_Pronoun();
}
}
Expand Up @@ -34,7 +34,6 @@
import hudson.model.TaskListener;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
Expand Down Expand Up @@ -341,7 +340,15 @@ private void add(TaskListener listener, SCMSourceObserver observer, GHRepository
public static final boolean defaultBuildForkPRHead = GitHubSCMSource.DescriptorImpl.defaultBuildForkPRHead;

@Inject private GitHubSCMSource.DescriptorImpl delegate;


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

@Override public String getDisplayName() {
return Messages.GitHubSCMNavigator_DisplayName();
}
Expand Down
Expand Up @@ -212,6 +212,12 @@ public String getRepository() {
return repository;
}

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

@Override
protected List<RefSpec> getRefSpecs() {
return new ArrayList<>(Arrays.asList(new RefSpec("+refs/heads/*:refs/remotes/origin/*"),
Expand Down Expand Up @@ -498,7 +504,7 @@ private void doRetrieve(SCMHeadObserver observer, TaskListener listener, GHRepos
continue;
}
}
SCMHead head = new SCMHead(branchName);
SCMHead head = new BranchSCMHead(branchName);
SCMRevision hash = new SCMRevisionImpl(head, entry.getValue().getSHA1());
observer.observe(head, hash);
if (!observer.isObserving()) {
Expand Down Expand Up @@ -740,7 +746,7 @@ public static void addAliases() {

@Override
public String getDisplayName() {
return "GitHub";
return Messages.GitHubSCMSource_DisplayName();
}

@Restricted(NoExternalUse.class)
Expand Down
Expand Up @@ -49,6 +49,14 @@ public final class PullRequestSCMHead extends SCMHead {
this.trusted = trusted;
}

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

public int getNumber() {
if (metadata != null) {
return Integer.parseInt(metadata.getId());
Expand Down
@@ -1,3 +1,5 @@
BranchSCMHead.Pronoun=Branch

GitHubBuildStatusNotification.CommitStatus.Good=This commit looks good
GitHubBuildStatusNotification.CommitStatus.Unstable=This commit has test failures
GitHubBuildStatusNotification.CommitStatus.Failure=This commit cannot be built
Expand All @@ -8,5 +10,10 @@ GitHubBuildStatusNotification.CommitStatusSet=GitHub has been notified of this c

GitHubSCMNavigator.DisplayName=GitHub Organization
GitHubSCMNavigator.Description=Scans a GitHub organization (or user account) for all repositories matching some defined markers.
GitHubSCMNavigator.Pronoun=Organization

GitHubSCMSource.DisplayName=GitHub
GitHubSCMSource.Pronoun=Repository
GitHubSCMSource.did_you_mean_to_use_to_match_all_branches=Did you mean to use * to match all branches?

PullRequestSCMHead.Pronoun=Pull Request

0 comments on commit 9dbc8d7

Please sign in to comment.