Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-34395] Updates based on manual testing
  • Loading branch information
stephenc committed Sep 7, 2017
1 parent e28cd4a commit 51415fa
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
Expand Up @@ -1324,6 +1324,7 @@ public FormValidation doCheckCredentialsId(@CheckForNull @AncestorInPath Item co
*
* @param context the context.
* @param apiUri the end-point.
* @param credentialsId the existing selection;
* @return the drop-down list.
* @since 2.2.0
*/
Expand Down
Expand Up @@ -36,6 +36,7 @@
import jenkins.scm.api.SCMProbe;
import jenkins.scm.api.SCMProbeStat;
import jenkins.scm.api.SCMRevision;
import org.eclipse.jgit.lib.Constants;
import org.kohsuke.github.GHCommit;
import org.kohsuke.github.GHContent;
import org.kohsuke.github.GHRef;
Expand All @@ -60,8 +61,10 @@ public GitHubSCMProbe(GitHub github, GHRepository repo, SCMHead head, SCMRevisio
if (head instanceof PullRequestSCMHead) {
PullRequestSCMHead pr = (PullRequestSCMHead) head;
this.ref = "refs/pull/" + pr.getNumber() + (pr.isMerge() ? "/merge" : "/head");
} else if (head instanceof GitHubTagSCMHead){
this.ref = Constants.R_TAGS + head.getName();
} else {
this.ref = "refs/heads/" + head.getName();
this.ref = Constants.R_HEADS + head.getName();
}
}

Expand Down
Expand Up @@ -94,7 +94,6 @@
import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy;
import jenkins.scm.api.trait.SCMSourceRequest;
import jenkins.scm.api.trait.SCMSourceTrait;
import jenkins.scm.api.trait.SCMSourceTraitDescriptor;
import jenkins.scm.api.trait.SCMTrait;
import jenkins.scm.api.trait.SCMTraitDescriptor;
import jenkins.scm.impl.ChangeRequestSCMHeadCategory;
Expand Down Expand Up @@ -887,7 +886,7 @@ public GHPermissionType fetch(String username) throws IOException, InterruptedEx
public SCMSourceCriteria.Probe create(@NonNull BranchSCMHead head,
@Nullable SCMRevisionImpl revisionInfo)
throws IOException, InterruptedException {
return GitHubSCMSource.this.createProbe(head, revisionInfo);
return new GitHubSCMProbe(github, ghRepository, head, revisionInfo);
}
}, new CriteriaWitness(listener))) {
listener.getLogger().format("%n %d branches were processed (query completed)%n", count);
Expand Down Expand Up @@ -937,8 +936,8 @@ public SCMSourceCriteria.Probe create(@NonNull PullRequestSCMHead head,
if (!trusted) {
listener.getLogger().format(" (not from a trusted source)%n");
}
return GitHubSCMSource.this
.createProbe(trusted ? head : head.getTarget(), null);
return new GitHubSCMProbe(github, ghRepository,
trusted ? head : head.getTarget(), null);
}
},
new SCMSourceRequest.LazyRevisionLambda<PullRequestSCMHead, SCMRevision, Void>() {
Expand Down Expand Up @@ -1018,7 +1017,7 @@ public SCMRevision create(@NonNull PullRequestSCMHead head,
public SCMSourceCriteria.Probe create(@NonNull GitHubTagSCMHead head,
@Nullable SCMRevisionImpl revisionInfo)
throws IOException, InterruptedException {
return GitHubSCMSource.this.createProbe(head, revisionInfo);
return new GitHubSCMProbe(github, ghRepository, head, revisionInfo);
}
}, new CriteriaWitness(listener))) {
listener.getLogger()
Expand Down Expand Up @@ -1490,11 +1489,9 @@ public SCMRevision getTrustedRevision(SCMRevision revision, final TaskListener l
* {@inheritDoc}
*/
protected boolean isCategoryEnabled(@NonNull SCMHeadCategory category) {
if (super.isCategoryEnabled(category)) {
for (SCMSourceTrait trait : traits) {
if (trait.isCategoryEnabled(category)) {
return true;
}
for (SCMSourceTrait trait : traits) {
if (trait.isCategoryEnabled(category)) {
return true;
}
}
return false;
Expand Down Expand Up @@ -1907,7 +1904,7 @@ protected SCMHeadCategory[] createCategories() {
return new SCMHeadCategory[]{
new UncategorizedSCMHeadCategory(Messages._GitHubSCMSource_UncategorizedCategory()),
new ChangeRequestSCMHeadCategory(Messages._GitHubSCMSource_ChangeRequestCategory()),
TagSCMHeadCategory.DEFAULT
new TagSCMHeadCategory(Messages._GitHubSCMSource_TagCategory())
};
}

Expand Down
Expand Up @@ -461,6 +461,8 @@ public void close() throws IOException {
*
* @param username the user.
* @return the permissions of the supplied user.
* @throws IOException if the permissions could not be retrieved.
* @throws InterruptedException if interrupted while retrieving the permissions.
*/
public GHPermissionType getPermissions(String username) throws IOException, InterruptedException {
synchronized (permissions) {
Expand Down
Expand Up @@ -26,4 +26,13 @@ public GitHubTagSCMHead(@NonNull String name, long timestamp) {
public long getTimestamp() {
return timestamp;
}

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

}
@@ -1,4 +1,5 @@
BranchSCMHead.Pronoun=Branch
GitHubTagSCMHead.Pronoun=Tag

ForkPullRequestDiscoveryTrait.contributorsDisplayName=Contributors
ForkPullRequestDiscoveryTrait.permissionsDisplayName=From users with Admin or Write permission
Expand Down Expand Up @@ -34,6 +35,7 @@ GitHubSCMNavigator.Pronoun=Organization
GitHubSCMNavigator.UncategorizedCategory=Repositories

GitHubSCMSource.ChangeRequestCategory=Pull Requests
GitHubSCMSource.TagCategory=Tags
GitHubSCMSource.DisplayName=GitHub
GitHubSCMSource.Pronoun=Repository
GitHubSCMSource.UncategorizedCategory=Branches
Expand Down

0 comments on commit 51415fa

Please sign in to comment.