From bcff70f53c32be1e83af85dff38c458d0f05af83 Mon Sep 17 00:00:00 2001 From: Nick Griffiths Date: Wed, 29 Jan 2020 17:15:43 +0000 Subject: [PATCH 01/49] [FIXED JENKINS-51519] Ignore archived repos. When "Exclude archived repositories" is added to the list of behaviours in the settings, repositories that have been archived in GitHub will not be processed. This is achieved using `witness.record(repo.getName(), false)`. --- .../ExcludeArchivedTrait.java | 54 +++++ .../GitHubSCMNavigator.java | 60 +++++- .../GitHubSCMNavigatorContext.java | 19 ++ .../ExcludeArchivedTrait/config.jelly | 5 + .../ExcludeArchivedTrait/help.html | 3 + .../github_branch_source/Messages.properties | 1 + .../GitHubSCMNavigatorTest.java | 169 +++++++++++++++- .../__files/body-cloudbeers-repos-v3FBW.json | 106 ++++++++++ .../body-cloudbeers-yolo-archived.json | 110 ++++++++++ ...body-orgs-cloudbeers-teams-repo-gOYDg.json | 94 +++++++++ .../api/__files/body-rate_limit-B5BGx.json | 29 +++ .../__files/body-stephenc-yolo-archived.json | 89 ++++++++ .../api/__files/body-user-repos-O8W78.json | 185 +++++++++++++++++ .../__files/body-users-stephenc-repos.json | 190 ++++++++++++++++++ .../mapping-cloudbeers-yolo-archived.json | 34 ++++ ...> mapping-orgs-cloudbeers-repo-gUIDg.json} | 0 .../mappings/mapping-rate_limit-B5BGx.json | 31 +++ .../mapping-stephenc-yolo-archived.json | 34 ++++ .../api/mappings/mapping-user-JRfTU.json | 34 ++++ .../mappings/mapping-user-repos-O8W78.json | 35 ++++ .../mapping-users-stephenc-repos.json | 34 ++++ 21 files changed, 1299 insertions(+), 17 deletions(-) create mode 100644 src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait.java create mode 100644 src/main/resources/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait/config.jelly create mode 100644 src/main/resources/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait/help.html create mode 100644 src/test/resources/api/__files/body-cloudbeers-yolo-archived.json create mode 100644 src/test/resources/api/__files/body-rate_limit-B5BGx.json create mode 100644 src/test/resources/api/__files/body-stephenc-yolo-archived.json create mode 100644 src/test/resources/api/__files/body-user-repos-O8W78.json create mode 100644 src/test/resources/api/__files/body-users-stephenc-repos.json create mode 100644 src/test/resources/api/mappings/mapping-cloudbeers-yolo-archived.json rename src/test/resources/api/mappings/{mapping-body-orgs-cloudbeers-repo-gUIDg.json => mapping-orgs-cloudbeers-repo-gUIDg.json} (100%) create mode 100644 src/test/resources/api/mappings/mapping-rate_limit-B5BGx.json create mode 100644 src/test/resources/api/mappings/mapping-stephenc-yolo-archived.json create mode 100644 src/test/resources/api/mappings/mapping-user-JRfTU.json create mode 100644 src/test/resources/api/mappings/mapping-user-repos-O8W78.json create mode 100644 src/test/resources/api/mappings/mapping-users-stephenc-repos.json diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait.java new file mode 100644 index 000000000..af65d5013 --- /dev/null +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait.java @@ -0,0 +1,54 @@ +package org.jenkinsci.plugins.github_branch_source; + +import hudson.Extension; +import jenkins.scm.api.trait.SCMNavigatorContext; +import jenkins.scm.api.trait.SCMNavigatorTrait; +import jenkins.scm.api.trait.SCMNavigatorTraitDescriptor; +import jenkins.scm.impl.trait.Selection; +import org.jenkinsci.Symbol; +import org.kohsuke.stapler.DataBoundConstructor; + +import javax.annotation.Nonnull; + +/** + * A {@link Selection} trait that will restrict the discovery of repositories that have been archived. + */ +public class ExcludeArchivedTrait extends SCMNavigatorTrait { + + /** + * Constructor for stapler. + */ + @DataBoundConstructor + public ExcludeArchivedTrait() { + } + + /** + * {@inheritDoc} + */ + @Override + protected void decorateContext(SCMNavigatorContext context) { + super.decorateContext(context); + GitHubSCMNavigatorContext ctx = (GitHubSCMNavigatorContext) context; + ctx.setExcludeArchived(true); + } + + /** + * Excluded archived repositories filter + */ + @Symbol("archivedRepositoriesFilter") + @Extension + @Selection + public static class DescriptorImpl extends SCMNavigatorTraitDescriptor { + + @Override + public Class getContextClass() { + return GitHubSCMNavigatorContext.class; + } + + @Nonnull + @Override + public String getDisplayName() { + return Messages.ExcludeArchivedTrait_displayName(); + } + } +} diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index ac67fd08c..af4a41d1d 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -951,7 +951,14 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru if (!repo.getOwnerName().equals(repoOwner)) { continue; // ignore repos in other orgs when using GHMyself } - if (request.process(repo.getName(), sourceFactory, null, witness)) { + + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + witness.record(repo.getName(), false); + listener.getLogger() + .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( + "Skipping repository %s because it is archived", repo.getName()))); + + } else if (request.process(repo.getName(), sourceFactory, null, witness)) { listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( "%d repositories were processed (query completed)", witness.getCount() @@ -979,7 +986,14 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru } for (GHRepository repo : repositories) { Connector.checkApiRateLimit(listener, github); - if (request.process(repo.getName(), sourceFactory, null, witness)) { + + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + witness.record(repo.getName(), false); + listener.getLogger() + .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( + "Skipping repository %s because it is archived", repo.getName()))); + + } else if (request.process(repo.getName(), sourceFactory, null, witness)) { listener.getLogger().println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( "%d repositories were processed (query completed)", witness.getCount() ))); @@ -1003,7 +1017,14 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru Connector.checkApiRateLimit(listener, github); for (GHRepository repo : user.listRepositories(100)) { Connector.checkApiRateLimit(listener, github); - if (request.process(repo.getName(), sourceFactory, null, witness)) { + + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + witness.record(repo.getName(), false); + listener.getLogger() + .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( + "Skipping repository %s because it is archived", repo.getName()))); + + } else if (request.process(repo.getName(), sourceFactory, null, witness)) { listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( "%d repositories were processed (query completed)", witness.getCount() @@ -1072,9 +1093,9 @@ public void visitSource(String sourceName, SCMSourceObserver observer) throw new AbortException(message); } - GitHubSCMNavigatorRequest request = new GitHubSCMNavigatorContext() - .withTraits(traits) - .newRequest(this, observer); + GitHubSCMNavigatorContext gitHubSCMNavigatorContext = new GitHubSCMNavigatorContext().withTraits(traits); + GitHubSCMNavigatorRequest request = gitHubSCMNavigatorContext.newRequest(this, observer); + try { SourceFactory sourceFactory = new SourceFactory(request); WitnessImpl witness = new WitnessImpl(listener); @@ -1094,7 +1115,14 @@ public void visitSource(String sourceName, SCMSourceObserver observer) listener.getLogger().format("Looking up %s repository of myself %s%n%n", sourceName, repoOwner); GHRepository repo = myself.getRepository(sourceName); if (repo != null && repo.getOwnerName().equals(repoOwner)) { - if (request.process(repo.getName(), sourceFactory, null, witness)) { + + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + witness.record(repo.getName(), false); + listener.getLogger() + .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( + "Skipping repository %s because it is archived", repo.getName()))); + + } else if (request.process(repo.getName(), sourceFactory, null, witness)) { listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( "%d repositories were processed (query completed)", witness.getCount() @@ -1117,7 +1145,14 @@ public void visitSource(String sourceName, SCMSourceObserver observer) .format("Looking up %s repository of organization %s%n%n", sourceName, repoOwner); GHRepository repo = org.getRepository(sourceName); if (repo != null) { - if (request.process(repo.getName(), sourceFactory, null, witness)) { + + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + witness.record(repo.getName(), false); + listener.getLogger() + .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( + "Skipping repository %s because it is archived", repo.getName()))); + + } else if (request.process(repo.getName(), sourceFactory, null, witness)) { listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( "%d repositories were processed (query completed)", witness.getCount() @@ -1142,7 +1177,14 @@ public void visitSource(String sourceName, SCMSourceObserver observer) listener.getLogger().format("Looking up %s repository of user %s%n%n", sourceName, repoOwner); GHRepository repo = user.getRepository(sourceName); if (repo != null) { - if (request.process(repo.getName(), sourceFactory, null, witness)) { + + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + witness.record(repo.getName(), false); + listener.getLogger() + .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( + "Skipping repository %s because it is archived", repo.getName()))); + + } else if (request.process(repo.getName(), sourceFactory, null, witness)) { listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( "%d repositories were processed (query completed)", witness.getCount() diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorContext.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorContext.java index 923c96e08..a864e7523 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorContext.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorContext.java @@ -40,6 +40,11 @@ public class GitHubSCMNavigatorContext extends SCMNavigatorContext + + diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait/help.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait/help.html new file mode 100644 index 000000000..ed55a6299 --- /dev/null +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait/help.html @@ -0,0 +1,3 @@ +
+ Exclude GitHub repositories that have been archived. If set, no jobs will be created for archived repositories. +
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties index 434470ca5..447b5165e 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties @@ -62,6 +62,7 @@ SSHCheckoutTrait.missingCredentials=The currently configured credentials cannot SSHCheckoutTrait.useAgentKey=- use build agent''s key - TagDiscoveryTrait.authorityDisplayName=Trust origin tags TagDiscoveryTrait.displayName=Discover tags +ExcludeArchivedTrait.displayName=Exclude archived repositories GitHubSCMNavigator.general=General GitHubSCMNavigator.withinRepository=Within repository diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java index f8cfcf702..522ae6a28 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java @@ -25,6 +25,12 @@ package org.jenkinsci.plugins.github_branch_source; +import com.cloudbees.plugins.credentials.Credentials; +import com.cloudbees.plugins.credentials.CredentialsScope; +import com.cloudbees.plugins.credentials.SystemCredentialsProvider; +import com.cloudbees.plugins.credentials.domains.Domain; +import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials; +import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl; import com.github.tomakehurst.wiremock.common.FileSource; import com.github.tomakehurst.wiremock.common.SingleRootFileSource; import com.github.tomakehurst.wiremock.core.WireMockConfiguration; @@ -33,7 +39,6 @@ import com.github.tomakehurst.wiremock.http.Request; import com.github.tomakehurst.wiremock.http.Response; import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.google.common.collect.Sets; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; import hudson.model.Action; @@ -76,6 +81,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; @@ -130,10 +136,13 @@ public String getName() { @Mock private SCMSourceOwner scmSourceOwner; + private BaseStandardCredentials credentials = new UsernamePasswordCredentialsImpl( + CredentialsScope.GLOBAL, "authenticated-user", null, "git-user", "git-secret"); + private GitHubSCMNavigator navigator; @Before - public void prepareMockGitHub() throws Exception { + public void prepareMockGitHub() { new File("src/test/resources/api/mappings").mkdirs(); new File("src/test/resources/api/__files").mkdirs(); new File("src/test/resources/raw/mappings").mkdirs(); @@ -146,7 +155,21 @@ public void prepareMockGitHub() throws Exception { get(urlMatching(".*")).atPriority(10).willReturn(aResponse().proxiedFrom("https://api.github.com/"))); githubRaw.stubFor(get(urlMatching(".*")).atPriority(10) .willReturn(aResponse().proxiedFrom("https://raw.githubusercontent.com/"))); - navigator = new GitHubSCMNavigator("http://localhost:" + githubApi.port(), "cloudbeers", null, null); + + setCredentials(Collections.emptyList()); + navigator = navigatorForRepoOwner("cloudbeers", null); + } + + private GitHubSCMNavigator navigatorForRepoOwner(String repoOwner, @Nullable String credentialsId) { + GitHubSCMNavigator navigator = new GitHubSCMNavigator(repoOwner); + navigator.setApiUri("http://localhost:" + githubApi.port()); + navigator.setCredentialsId(credentialsId); + return navigator; + } + + private void setCredentials(List credentials) { + SystemCredentialsProvider.getInstance().setDomainCredentialsMap( + Collections.singletonMap(Domain.global(), credentials)); } @Test @@ -156,7 +179,7 @@ public void fetchSmokes() throws Exception { navigator.visitSources(SCMSourceObserver.filter(observer, "yolo")); - assertThat(projectNames, Matchers.contains("yolo")); + assertThat(projectNames, contains("yolo")); } @Test @@ -169,17 +192,147 @@ public void fetchReposFromTeamSlug() throws Exception { navigator.setTraits(traits); navigator.visitSources(SCMSourceObserver.filter(observer, "Hello-World", "github-branch-source-plugin")); - assertEquals(projectNames, Sets.newHashSet("Hello-World", "github-branch-source-plugin")); + assertThat(projectNames, containsInAnyOrder("Hello-World", "github-branch-source-plugin")); } @Test - public void fetchReposWithOrg() throws Exception { + public void fetchOneRepo_BelongingToAuthenticatedUser() throws Exception { + setCredentials(Collections.singletonList(credentials)); + navigator = navigatorForRepoOwner("stephenc", credentials.getId()); final Set projectNames = new HashSet<>(); final SCMSourceObserver observer = getObserver(projectNames); - navigator.visitSources(SCMSourceObserver.filter(observer, "Hello-World", "github-branch-source-plugin")); + navigator.visitSources(SCMSourceObserver.filter(observer, "yolo-archived")); + + assertThat(projectNames, containsInAnyOrder("yolo-archived")); + } + + @Test + public void fetchOneRepo_BelongingToAuthenticatedUser_ExcludingArchived() throws Exception { + setCredentials(Collections.singletonList(credentials)); + navigator = navigatorForRepoOwner("stephenc", credentials.getId()); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(SCMSourceObserver.filter(observer, "yolo-archived")); + + assertThat(projectNames, empty()); + } + + @Test + public void fetchOneRepo_BelongingToOrg() throws Exception { + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(SCMSourceObserver.filter(observer, "yolo-archived")); + + assertThat(projectNames, containsInAnyOrder("yolo-archived")); + } + + @Test + public void fetchOneRepo_BelongingToOrg_ExcludingArchived() throws Exception { + navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(SCMSourceObserver.filter(observer, "yolo-archived")); + + assertThat(projectNames, empty()); + } + + @Test + public void fetchOneRepo_BelongingToUser() throws Exception { + navigator = navigatorForRepoOwner("stephenc", null); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(SCMSourceObserver.filter(observer, "yolo-archived")); + + assertThat(projectNames, containsInAnyOrder("yolo-archived")); + } + + @Test + public void fetchOneRepo_BelongingToUser_ExcludingArchived() throws Exception { + navigator = navigatorForRepoOwner("stephenc", null); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(SCMSourceObserver.filter(observer, "yolo-archived")); + + assertThat(projectNames, empty()); + } + + @Test + public void fetchRepos_BelongingToAuthenticatedUser() throws Exception { + setCredentials(Collections.singletonList(credentials)); + navigator = navigatorForRepoOwner("stephenc", credentials.getId()); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(observer); + + assertThat(projectNames, containsInAnyOrder("yolo", "yolo-archived")); + } + + @Test + public void fetchRepos_BelongingToAuthenticatedUser_ExcludingArchived() throws Exception { + setCredentials(Collections.singletonList(credentials)); + navigator = navigatorForRepoOwner("stephenc", credentials.getId()); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(observer); + + assertThat(projectNames, containsInAnyOrder("yolo")); + } + + @Test + public void fetchRepos_BelongingToOrg() throws Exception { + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources( + SCMSourceObserver.filter(observer, "Hello-World", "github-branch-source-plugin", "yolo-archived")); + + assertThat(projectNames, containsInAnyOrder("Hello-World", "github-branch-source-plugin", "yolo-archived")); + } + + @Test + public void fetchRepos_BelongingToOrg_ExcludingArchived() throws Exception { + navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources( + SCMSourceObserver.filter(observer, "Hello-World", "github-branch-source-plugin", "yolo-archived")); + + assertThat(projectNames, containsInAnyOrder("Hello-World", "github-branch-source-plugin")); + } + + @Test + public void fetchRepos_BelongingToUser() throws Exception { + navigator = navigatorForRepoOwner("stephenc", null); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(observer); + + assertThat(projectNames, containsInAnyOrder("yolo", "yolo-archived")); + } + + @Test + public void fetchRepos_BelongingToUser_ExcludingArchived() throws Exception { + navigator = navigatorForRepoOwner("stephenc", null); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + final Set projectNames = new HashSet<>(); + final SCMSourceObserver observer = getObserver(projectNames); + + navigator.visitSources(observer); - assertEquals(projectNames, Sets.newHashSet("Hello-World", "github-branch-source-plugin")); + assertThat(projectNames, containsInAnyOrder("yolo")); } @Test diff --git a/src/test/resources/api/__files/body-cloudbeers-repos-v3FBW.json b/src/test/resources/api/__files/body-cloudbeers-repos-v3FBW.json index f5e4bc9af..60f760b38 100644 --- a/src/test/resources/api/__files/body-cloudbeers-repos-v3FBW.json +++ b/src/test/resources/api/__files/body-cloudbeers-repos-v3FBW.json @@ -76,6 +76,7 @@ "language": "Java", "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 1, @@ -168,6 +169,7 @@ "language": "Java", "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 0, @@ -260,6 +262,7 @@ "language": "HTML", "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": true, "forks_count": 0, @@ -352,6 +355,7 @@ "language": null, "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 0, @@ -444,6 +448,7 @@ "language": "Go", "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 87, @@ -536,6 +541,7 @@ "language": "Groovy", "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 10, @@ -628,6 +634,100 @@ "language": null, "has_issues": true, "has_downloads": true, + "archived": false, + "has_wiki": true, + "has_pages": false, + "forks_count": 3, + "mirror_url": null, + "open_issues_count": 1, + "forks": 3, + "open_issues": 1, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": false, + "push": false, + "pull": true + } +}, { + "id": 43041241, + "name": "yolo-archived", + "full_name": "cloudbeers/yolo-archived", + "owner": { + "login": "cloudbeers", + "id": 4181899, + "avatar_url": "https://avatars.githubusercontent.com/u/4181899?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/cloudbeers", + "html_url": "https://github.com/cloudbeers", + "followers_url": "https://api.github.com/users/cloudbeers/followers", + "following_url": "https://api.github.com/users/cloudbeers/following{/other_user}", + "gists_url": "https://api.github.com/users/cloudbeers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/cloudbeers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/cloudbeers/subscriptions", + "organizations_url": "https://api.github.com/users/cloudbeers/orgs", + "repos_url": "https://api.github.com/users/cloudbeers/repos", + "events_url": "https://api.github.com/users/cloudbeers/events{/privacy}", + "received_events_url": "https://api.github.com/users/cloudbeers/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/cloudbeers/yolo-archived", + "description": "It lived once, and then it was archived", + "fork": false, + "url": "https://api.github.com/repos/cloudbeers/yolo-archived", + "forks_url": "https://api.github.com/repos/cloudbeers/yolo-archived/forks", + "keys_url": "https://api.github.com/repos/cloudbeers/yolo-archived/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/cloudbeers/yolo-archived/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/cloudbeers/yolo-archived/teams", + "hooks_url": "https://api.github.com/repos/cloudbeers/yolo-archived/hooks", + "issue_events_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues/events{/number}", + "events_url": "https://api.github.com/repos/cloudbeers/yolo-archived/events", + "assignees_url": "https://api.github.com/repos/cloudbeers/yolo-archived/assignees{/user}", + "branches_url": "https://api.github.com/repos/cloudbeers/yolo-archived/branches{/branch}", + "tags_url": "https://api.github.com/repos/cloudbeers/yolo-archived/tags", + "blobs_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/cloudbeers/yolo-archived/statuses/{sha}", + "languages_url": "https://api.github.com/repos/cloudbeers/yolo-archived/languages", + "stargazers_url": "https://api.github.com/repos/cloudbeers/yolo-archived/stargazers", + "contributors_url": "https://api.github.com/repos/cloudbeers/yolo-archived/contributors", + "subscribers_url": "https://api.github.com/repos/cloudbeers/yolo-archived/subscribers", + "subscription_url": "https://api.github.com/repos/cloudbeers/yolo-archived/subscription", + "commits_url": "https://api.github.com/repos/cloudbeers/yolo-archived/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/cloudbeers/yolo-archived/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/cloudbeers/yolo-archived/contents/{+path}", + "compare_url": "https://api.github.com/repos/cloudbeers/yolo-archived/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/cloudbeers/yolo-archived/merges", + "archive_url": "https://api.github.com/repos/cloudbeers/yolo-archived/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/cloudbeers/yolo-archived/downloads", + "issues_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues{/number}", + "pulls_url": "https://api.github.com/repos/cloudbeers/yolo-archived/pulls{/number}", + "milestones_url": "https://api.github.com/repos/cloudbeers/yolo-archived/milestones{/number}", + "notifications_url": "https://api.github.com/repos/cloudbeers/yolo-archived/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/cloudbeers/yolo-archived/labels{/name}", + "releases_url": "https://api.github.com/repos/cloudbeers/yolo-archived/releases{/id}", + "deployments_url": "https://api.github.com/repos/cloudbeers/yolo-archived/deployments", + "created_at": "2015-09-24T02:58:30Z", + "updated_at": "2016-12-07T23:55:35Z", + "pushed_at": "2016-12-01T16:07:01Z", + "git_url": "git://github.com/cloudbeers/yolo-archived.git", + "ssh_url": "git@github.com:cloudbeers/yolo-archived.git", + "clone_url": "https://github.com/cloudbeers/yolo-archived.git", + "svn_url": "https://github.com/cloudbeers/yolo-archived", + "homepage": "http://yolo-archived.example.com", + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "archived": true, "has_wiki": true, "has_pages": false, "forks_count": 3, @@ -720,6 +820,7 @@ "language": null, "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 0, @@ -812,6 +913,7 @@ "language": "Groovy", "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 3, @@ -904,6 +1006,7 @@ "language": "Java", "has_issues": false, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 0, @@ -996,6 +1099,7 @@ "language": "JavaScript", "has_issues": false, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 0, @@ -1088,6 +1192,7 @@ "language": "Groovy", "has_issues": false, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 0, @@ -1180,6 +1285,7 @@ "language": "Makefile", "has_issues": true, "has_downloads": true, + "archived": false, "has_wiki": true, "has_pages": false, "forks_count": 0, diff --git a/src/test/resources/api/__files/body-cloudbeers-yolo-archived.json b/src/test/resources/api/__files/body-cloudbeers-yolo-archived.json new file mode 100644 index 000000000..145b60966 --- /dev/null +++ b/src/test/resources/api/__files/body-cloudbeers-yolo-archived.json @@ -0,0 +1,110 @@ +{ + "id": 43041241, + "name": "yolo-archived", + "full_name": "cloudbeers/yolo-archived", + "owner": { + "login": "cloudbeers", + "id": 4181899, + "avatar_url": "https://avatars.githubusercontent.com/u/4181899?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/cloudbeers", + "html_url": "https://github.com/cloudbeers", + "followers_url": "https://api.github.com/users/cloudbeers/followers", + "following_url": "https://api.github.com/users/cloudbeers/following{/other_user}", + "gists_url": "https://api.github.com/users/cloudbeers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/cloudbeers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/cloudbeers/subscriptions", + "organizations_url": "https://api.github.com/users/cloudbeers/orgs", + "repos_url": "https://api.github.com/users/cloudbeers/repos", + "events_url": "https://api.github.com/users/cloudbeers/events{/privacy}", + "received_events_url": "https://api.github.com/users/cloudbeers/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/cloudbeers/yolo-archived", + "description": "It lived once, and then it was archived", + "fork": false, + "url": "https://api.github.com/repos/cloudbeers/yolo-archived", + "forks_url": "https://api.github.com/repos/cloudbeers/yolo-archived/forks", + "keys_url": "https://api.github.com/repos/cloudbeers/yolo-archived/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/cloudbeers/yolo-archived/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/cloudbeers/yolo-archived/teams", + "hooks_url": "https://api.github.com/repos/cloudbeers/yolo-archived/hooks", + "issue_events_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues/events{/number}", + "events_url": "https://api.github.com/repos/cloudbeers/yolo-archived/events", + "assignees_url": "https://api.github.com/repos/cloudbeers/yolo-archived/assignees{/user}", + "branches_url": "https://api.github.com/repos/cloudbeers/yolo-archived/branches{/branch}", + "tags_url": "https://api.github.com/repos/cloudbeers/yolo-archived/tags", + "blobs_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/cloudbeers/yolo-archived/statuses/{sha}", + "languages_url": "https://api.github.com/repos/cloudbeers/yolo-archived/languages", + "stargazers_url": "https://api.github.com/repos/cloudbeers/yolo-archived/stargazers", + "contributors_url": "https://api.github.com/repos/cloudbeers/yolo-archived/contributors", + "subscribers_url": "https://api.github.com/repos/cloudbeers/yolo-archived/subscribers", + "subscription_url": "https://api.github.com/repos/cloudbeers/yolo-archived/subscription", + "commits_url": "https://api.github.com/repos/cloudbeers/yolo-archived/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/cloudbeers/yolo-archived/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/cloudbeers/yolo-archived/contents/{+path}", + "compare_url": "https://api.github.com/repos/cloudbeers/yolo-archived/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/cloudbeers/yolo-archived/merges", + "archive_url": "https://api.github.com/repos/cloudbeers/yolo-archived/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/cloudbeers/yolo-archived/downloads", + "issues_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues{/number}", + "pulls_url": "https://api.github.com/repos/cloudbeers/yolo-archived/pulls{/number}", + "milestones_url": "https://api.github.com/repos/cloudbeers/yolo-archived/milestones{/number}", + "notifications_url": "https://api.github.com/repos/cloudbeers/yolo-archived/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/cloudbeers/yolo-archived/labels{/name}", + "releases_url": "https://api.github.com/repos/cloudbeers/yolo-archived/releases{/id}", + "deployments_url": "https://api.github.com/repos/cloudbeers/yolo-archived/deployments", + "created_at": "2015-09-24T02:58:30Z", + "updated_at": "2016-12-07T23:55:35Z", + "pushed_at": "2016-12-01T16:07:01Z", + "git_url": "git://github.com/cloudbeers/yolo-archived.git", + "ssh_url": "git@github.com:cloudbeers/yolo-archived.git", + "clone_url": "https://github.com/cloudbeers/yolo-archived.git", + "svn_url": "https://github.com/cloudbeers/yolo-archived", + "homepage": "http://yolo-archived.example.com", + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "archived": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 3, + "mirror_url": null, + "open_issues_count": 1, + "forks": 3, + "open_issues": 1, + "watchers": 0, + "default_branch": "master", + "organization": { + "login": "cloudbeers", + "id": 4181899, + "avatar_url": "https://avatars.githubusercontent.com/u/4181899?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/cloudbeers", + "html_url": "https://github.com/cloudbeers", + "followers_url": "https://api.github.com/users/cloudbeers/followers", + "following_url": "https://api.github.com/users/cloudbeers/following{/other_user}", + "gists_url": "https://api.github.com/users/cloudbeers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/cloudbeers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/cloudbeers/subscriptions", + "organizations_url": "https://api.github.com/users/cloudbeers/orgs", + "repos_url": "https://api.github.com/users/cloudbeers/repos", + "events_url": "https://api.github.com/users/cloudbeers/events{/privacy}", + "received_events_url": "https://api.github.com/users/cloudbeers/received_events", + "type": "Organization", + "site_admin": false + }, + "network_count": 3, + "subscribers_count": 2 +} \ No newline at end of file diff --git a/src/test/resources/api/__files/body-orgs-cloudbeers-teams-repo-gOYDg.json b/src/test/resources/api/__files/body-orgs-cloudbeers-teams-repo-gOYDg.json index ce44c46a4..7c79822bb 100644 --- a/src/test/resources/api/__files/body-orgs-cloudbeers-teams-repo-gOYDg.json +++ b/src/test/resources/api/__files/body-orgs-cloudbeers-teams-repo-gOYDg.json @@ -218,5 +218,99 @@ "url": "https://api.github.com/licenses/mit", "node_id": "MDc6TGljZW5zZW1pdA==" } + }, + { + "id": 43041241, + "name": "yolo-archived", + "full_name": "cloudbeers/yolo-archived", + "owner": { + "login": "cloudbeers", + "id": 4181899, + "avatar_url": "https://avatars.githubusercontent.com/u/4181899?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/cloudbeers", + "html_url": "https://github.com/cloudbeers", + "followers_url": "https://api.github.com/users/cloudbeers/followers", + "following_url": "https://api.github.com/users/cloudbeers/following{/other_user}", + "gists_url": "https://api.github.com/users/cloudbeers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/cloudbeers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/cloudbeers/subscriptions", + "organizations_url": "https://api.github.com/users/cloudbeers/orgs", + "repos_url": "https://api.github.com/users/cloudbeers/repos", + "events_url": "https://api.github.com/users/cloudbeers/events{/privacy}", + "received_events_url": "https://api.github.com/users/cloudbeers/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/cloudbeers/yolo-archived", + "description": "It lived once, and then it was archived", + "fork": false, + "url": "https://api.github.com/repos/cloudbeers/yolo-archived", + "forks_url": "https://api.github.com/repos/cloudbeers/yolo-archived/forks", + "keys_url": "https://api.github.com/repos/cloudbeers/yolo-archived/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/cloudbeers/yolo-archived/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/cloudbeers/yolo-archived/teams", + "hooks_url": "https://api.github.com/repos/cloudbeers/yolo-archived/hooks", + "issue_events_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues/events{/number}", + "events_url": "https://api.github.com/repos/cloudbeers/yolo-archived/events", + "assignees_url": "https://api.github.com/repos/cloudbeers/yolo-archived/assignees{/user}", + "branches_url": "https://api.github.com/repos/cloudbeers/yolo-archived/branches{/branch}", + "tags_url": "https://api.github.com/repos/cloudbeers/yolo-archived/tags", + "blobs_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/cloudbeers/yolo-archived/statuses/{sha}", + "languages_url": "https://api.github.com/repos/cloudbeers/yolo-archived/languages", + "stargazers_url": "https://api.github.com/repos/cloudbeers/yolo-archived/stargazers", + "contributors_url": "https://api.github.com/repos/cloudbeers/yolo-archived/contributors", + "subscribers_url": "https://api.github.com/repos/cloudbeers/yolo-archived/subscribers", + "subscription_url": "https://api.github.com/repos/cloudbeers/yolo-archived/subscription", + "commits_url": "https://api.github.com/repos/cloudbeers/yolo-archived/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/cloudbeers/yolo-archived/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/cloudbeers/yolo-archived/contents/{+path}", + "compare_url": "https://api.github.com/repos/cloudbeers/yolo-archived/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/cloudbeers/yolo-archived/merges", + "archive_url": "https://api.github.com/repos/cloudbeers/yolo-archived/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/cloudbeers/yolo-archived/downloads", + "issues_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues{/number}", + "pulls_url": "https://api.github.com/repos/cloudbeers/yolo-archived/pulls{/number}", + "milestones_url": "https://api.github.com/repos/cloudbeers/yolo-archived/milestones{/number}", + "notifications_url": "https://api.github.com/repos/cloudbeers/yolo-archived/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/cloudbeers/yolo-archived/labels{/name}", + "releases_url": "https://api.github.com/repos/cloudbeers/yolo-archived/releases{/id}", + "deployments_url": "https://api.github.com/repos/cloudbeers/yolo-archived/deployments", + "created_at": "2015-09-24T02:58:30Z", + "updated_at": "2016-12-07T23:55:35Z", + "pushed_at": "2016-12-01T16:07:01Z", + "git_url": "git://github.com/cloudbeers/yolo-archived.git", + "ssh_url": "git@github.com:cloudbeers/yolo-archived.git", + "clone_url": "https://github.com/cloudbeers/yolo-archived.git", + "svn_url": "https://github.com/cloudbeers/yolo-archived", + "homepage": "http://yolo-archived.example.com", + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "archived": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 3, + "mirror_url": null, + "open_issues_count": 1, + "forks": 3, + "open_issues": 1, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": false, + "push": false, + "pull": true + } } ] \ No newline at end of file diff --git a/src/test/resources/api/__files/body-rate_limit-B5BGx.json b/src/test/resources/api/__files/body-rate_limit-B5BGx.json new file mode 100644 index 000000000..37872f34b --- /dev/null +++ b/src/test/resources/api/__files/body-rate_limit-B5BGx.json @@ -0,0 +1,29 @@ +{ + "resources": { + "core": { + "limit": 5000, + "remaining": 4999, + "reset": 1372700873 + }, + "search": { + "limit": 30, + "remaining": 18, + "reset": 1372697452 + }, + "graphql": { + "limit": 5000, + "remaining": 4993, + "reset": 1372700389 + }, + "integration_manifest": { + "limit": 5000, + "remaining": 4999, + "reset": 1551806725 + } + }, + "rate": { + "limit": 5000, + "remaining": 4999, + "reset": 1372700873 + } +} \ No newline at end of file diff --git a/src/test/resources/api/__files/body-stephenc-yolo-archived.json b/src/test/resources/api/__files/body-stephenc-yolo-archived.json new file mode 100644 index 000000000..f7e81737e --- /dev/null +++ b/src/test/resources/api/__files/body-stephenc-yolo-archived.json @@ -0,0 +1,89 @@ +{ + "id": 75305445, + "name": "yolo-archived", + "full_name": "stephenc/yolo-archived", + "owner": { + "login": "stephenc", + "id": 209336, + "avatar_url": "https://avatars.githubusercontent.com/u/209336?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/stephenc", + "html_url": "https://github.com/stephenc", + "followers_url": "https://api.github.com/users/stephenc/followers", + "following_url": "https://api.github.com/users/stephenc/following{/other_user}", + "gists_url": "https://api.github.com/users/stephenc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/stephenc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/stephenc/subscriptions", + "organizations_url": "https://api.github.com/users/stephenc/orgs", + "repos_url": "https://api.github.com/users/stephenc/repos", + "events_url": "https://api.github.com/users/stephenc/events{/privacy}", + "received_events_url": "https://api.github.com/users/stephenc/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/stephenc/yolo-archived", + "description": "It lived once, and then it was archived", + "fork": true, + "url": "https://api.github.com/repos/stephenc/yolo-archived", + "forks_url": "https://api.github.com/repos/stephenc/yolo-archived/forks", + "keys_url": "https://api.github.com/repos/stephenc/yolo-archived/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/stephenc/yolo-archived/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/stephenc/yolo-archived/teams", + "hooks_url": "https://api.github.com/repos/stephenc/yolo-archived/hooks", + "issue_events_url": "https://api.github.com/repos/stephenc/yolo-archived/issues/events{/number}", + "events_url": "https://api.github.com/repos/stephenc/yolo-archived/events", + "assignees_url": "https://api.github.com/repos/stephenc/yolo-archived/assignees{/user}", + "branches_url": "https://api.github.com/repos/stephenc/yolo-archived/branches{/branch}", + "tags_url": "https://api.github.com/repos/stephenc/yolo-archived/tags", + "blobs_url": "https://api.github.com/repos/stephenc/yolo-archived/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/stephenc/yolo-archived/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/stephenc/yolo-archived/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/stephenc/yolo-archived/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/stephenc/yolo-archived/statuses/{sha}", + "languages_url": "https://api.github.com/repos/stephenc/yolo-archived/languages", + "stargazers_url": "https://api.github.com/repos/stephenc/yolo-archived/stargazers", + "contributors_url": "https://api.github.com/repos/stephenc/yolo-archived/contributors", + "subscribers_url": "https://api.github.com/repos/stephenc/yolo-archived/subscribers", + "subscription_url": "https://api.github.com/repos/stephenc/yolo-archived/subscription", + "commits_url": "https://api.github.com/repos/stephenc/yolo-archived/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/stephenc/yolo-archived/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/stephenc/yolo-archived/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/stephenc/yolo-archived/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/stephenc/yolo-archived/contents/{+path}", + "compare_url": "https://api.github.com/repos/stephenc/yolo-archived/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/stephenc/yolo-archived/merges", + "archive_url": "https://api.github.com/repos/stephenc/yolo-archived/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/stephenc/yolo-archived/downloads", + "issues_url": "https://api.github.com/repos/stephenc/yolo-archived/issues{/number}", + "pulls_url": "https://api.github.com/repos/stephenc/yolo-archived/pulls{/number}", + "milestones_url": "https://api.github.com/repos/stephenc/yolo-archived/milestones{/number}", + "notifications_url": "https://api.github.com/repos/stephenc/yolo-archived/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/stephenc/yolo-archived/labels{/name}", + "releases_url": "https://api.github.com/repos/stephenc/yolo-archived/releases{/id}", + "deployments_url": "https://api.github.com/repos/stephenc/yolo-archived/deployments", + "created_at": "2016-12-01T15:25:10Z", + "updated_at": "2016-11-21T22:53:53Z", + "pushed_at": "2016-12-01T16:07:01Z", + "git_url": "git://github.com/stephenc/yolo-archived.git", + "ssh_url": "git@github.com:stephenc/yolo-archived.git", + "clone_url": "https://github.com/stephenc/yolo-archived.git", + "svn_url": "https://github.com/stephenc/yolo-archived", + "homepage": null, + "size": 2, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_downloads": true, + "archived": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" +} \ No newline at end of file diff --git a/src/test/resources/api/__files/body-user-repos-O8W78.json b/src/test/resources/api/__files/body-user-repos-O8W78.json new file mode 100644 index 000000000..1e4121f59 --- /dev/null +++ b/src/test/resources/api/__files/body-user-repos-O8W78.json @@ -0,0 +1,185 @@ +[ + { + "id": 75305444, + "name": "yolo", + "full_name": "stephenc/yolo", + "owner": { + "login": "stephenc", + "id": 209336, + "avatar_url": "https://avatars.githubusercontent.com/u/209336?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/stephenc", + "html_url": "https://github.com/stephenc", + "followers_url": "https://api.github.com/users/stephenc/followers", + "following_url": "https://api.github.com/users/stephenc/following{/other_user}", + "gists_url": "https://api.github.com/users/stephenc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/stephenc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/stephenc/subscriptions", + "organizations_url": "https://api.github.com/users/stephenc/orgs", + "repos_url": "https://api.github.com/users/stephenc/repos", + "events_url": "https://api.github.com/users/stephenc/events{/privacy}", + "received_events_url": "https://api.github.com/users/stephenc/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/stephenc/yolo", + "description": null, + "fork": true, + "url": "https://api.github.com/repos/stephenc/yolo", + "forks_url": "https://api.github.com/repos/stephenc/yolo/forks", + "keys_url": "https://api.github.com/repos/stephenc/yolo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/stephenc/yolo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/stephenc/yolo/teams", + "hooks_url": "https://api.github.com/repos/stephenc/yolo/hooks", + "issue_events_url": "https://api.github.com/repos/stephenc/yolo/issues/events{/number}", + "events_url": "https://api.github.com/repos/stephenc/yolo/events", + "assignees_url": "https://api.github.com/repos/stephenc/yolo/assignees{/user}", + "branches_url": "https://api.github.com/repos/stephenc/yolo/branches{/branch}", + "tags_url": "https://api.github.com/repos/stephenc/yolo/tags", + "blobs_url": "https://api.github.com/repos/stephenc/yolo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/stephenc/yolo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/stephenc/yolo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/stephenc/yolo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/stephenc/yolo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/stephenc/yolo/languages", + "stargazers_url": "https://api.github.com/repos/stephenc/yolo/stargazers", + "contributors_url": "https://api.github.com/repos/stephenc/yolo/contributors", + "subscribers_url": "https://api.github.com/repos/stephenc/yolo/subscribers", + "subscription_url": "https://api.github.com/repos/stephenc/yolo/subscription", + "commits_url": "https://api.github.com/repos/stephenc/yolo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/stephenc/yolo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/stephenc/yolo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/stephenc/yolo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/stephenc/yolo/contents/{+path}", + "compare_url": "https://api.github.com/repos/stephenc/yolo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/stephenc/yolo/merges", + "archive_url": "https://api.github.com/repos/stephenc/yolo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/stephenc/yolo/downloads", + "issues_url": "https://api.github.com/repos/stephenc/yolo/issues{/number}", + "pulls_url": "https://api.github.com/repos/stephenc/yolo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/stephenc/yolo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/stephenc/yolo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/stephenc/yolo/labels{/name}", + "releases_url": "https://api.github.com/repos/stephenc/yolo/releases{/id}", + "deployments_url": "https://api.github.com/repos/stephenc/yolo/deployments", + "created_at": "2016-12-01T15:25:10Z", + "updated_at": "2016-11-21T22:53:53Z", + "pushed_at": "2016-12-01T16:07:01Z", + "git_url": "git://github.com/stephenc/yolo.git", + "ssh_url": "git@github.com:stephenc/yolo.git", + "clone_url": "https://github.com/stephenc/yolo.git", + "svn_url": "https://github.com/stephenc/yolo", + "homepage": null, + "size": 2, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_downloads": true, + "archived": false, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + { + "id": 43041241, + "name": "yolo-archived", + "full_name": "stephenc/yolo-archived", + "owner": { + "login": "stephenc", + "id": 209336, + "avatar_url": "https://avatars.githubusercontent.com/u/209336?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/stephenc", + "html_url": "https://github.com/stephenc", + "followers_url": "https://api.github.com/users/stephenc/followers", + "following_url": "https://api.github.com/users/stephenc/following{/other_user}", + "gists_url": "https://api.github.com/users/stephenc/gists{/gist_id}", + "starred_url": "https://api.github.com/users/stephenc/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/stephenc/subscriptions", + "organizations_url": "https://api.github.com/users/stephenc/orgs", + "repos_url": "https://api.github.com/users/stephenc/repos", + "events_url": "https://api.github.com/users/stephenc/events{/privacy}", + "received_events_url": "https://api.github.com/users/stephenc/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/stephenc/yolo-archived", + "description": "It lived once, and then it was archived", + "fork": false, + "url": "https://api.github.com/repos/stephenc/yolo-archived", + "forks_url": "https://api.github.com/repos/stephenc/yolo-archived/forks", + "keys_url": "https://api.github.com/repos/stephenc/yolo-archived/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/stephenc/yolo-archived/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/stephenc/yolo-archived/teams", + "hooks_url": "https://api.github.com/repos/stephenc/yolo-archived/hooks", + "issue_events_url": "https://api.github.com/repos/stephenc/yolo-archived/issues/events{/number}", + "events_url": "https://api.github.com/repos/stephenc/yolo-archived/events", + "assignees_url": "https://api.github.com/repos/stephenc/yolo-archived/assignees{/user}", + "branches_url": "https://api.github.com/repos/stephenc/yolo-archived/branches{/branch}", + "tags_url": "https://api.github.com/repos/stephenc/yolo-archived/tags", + "blobs_url": "https://api.github.com/repos/stephenc/yolo-archived/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/stephenc/yolo-archived/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/stephenc/yolo-archived/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/stephenc/yolo-archived/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/stephenc/yolo-archived/statuses/{sha}", + "languages_url": "https://api.github.com/repos/stephenc/yolo-archived/languages", + "stargazers_url": "https://api.github.com/repos/stephenc/yolo-archived/stargazers", + "contributors_url": "https://api.github.com/repos/stephenc/yolo-archived/contributors", + "subscribers_url": "https://api.github.com/repos/stephenc/yolo-archived/subscribers", + "subscription_url": "https://api.github.com/repos/stephenc/yolo-archived/subscription", + "commits_url": "https://api.github.com/repos/stephenc/yolo-archived/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/stephenc/yolo-archived/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/stephenc/yolo-archived/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/stephenc/yolo-archived/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/stephenc/yolo-archived/contents/{+path}", + "compare_url": "https://api.github.com/repos/stephenc/yolo-archived/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/stephenc/yolo-archived/merges", + "archive_url": "https://api.github.com/repos/stephenc/yolo-archived/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/stephenc/yolo-archived/downloads", + "issues_url": "https://api.github.com/repos/stephenc/yolo-archived/issues{/number}", + "pulls_url": "https://api.github.com/repos/stephenc/yolo-archived/pulls{/number}", + "milestones_url": "https://api.github.com/repos/stephenc/yolo-archived/milestones{/number}", + "notifications_url": "https://api.github.com/repos/stephenc/yolo-archived/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/stephenc/yolo-archived/labels{/name}", + "releases_url": "https://api.github.com/repos/stephenc/yolo-archived/releases{/id}", + "deployments_url": "https://api.github.com/repos/stephenc/yolo-archived/deployments", + "created_at": "2015-09-24T02:58:30Z", + "updated_at": "2016-12-07T23:55:35Z", + "pushed_at": "2016-12-01T16:07:01Z", + "git_url": "git://github.com/stephenc/yolo-archived.git", + "ssh_url": "git@github.com:stephenc/yolo-archived.git", + "clone_url": "https://github.com/stephenc/yolo-archived.git", + "svn_url": "https://github.com/stephenc/yolo-archived", + "homepage": "http://yolo-archived.example.com", + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "archived": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 3, + "mirror_url": null, + "open_issues_count": 1, + "forks": 3, + "open_issues": 1, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": false, + "push": false, + "pull": true + } + } +] \ No newline at end of file diff --git a/src/test/resources/api/__files/body-users-stephenc-repos.json b/src/test/resources/api/__files/body-users-stephenc-repos.json new file mode 100644 index 000000000..f00457514 --- /dev/null +++ b/src/test/resources/api/__files/body-users-stephenc-repos.json @@ -0,0 +1,190 @@ +[ + { + "id": 43041240, + "name": "yolo", + "full_name": "cloudbeers/yolo", + "owner": { + "login": "cloudbeers", + "id": 4181899, + "avatar_url": "https://avatars.githubusercontent.com/u/4181899?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/cloudbeers", + "html_url": "https://github.com/cloudbeers", + "followers_url": "https://api.github.com/users/cloudbeers/followers", + "following_url": "https://api.github.com/users/cloudbeers/following{/other_user}", + "gists_url": "https://api.github.com/users/cloudbeers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/cloudbeers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/cloudbeers/subscriptions", + "organizations_url": "https://api.github.com/users/cloudbeers/orgs", + "repos_url": "https://api.github.com/users/cloudbeers/repos", + "events_url": "https://api.github.com/users/cloudbeers/events{/privacy}", + "received_events_url": "https://api.github.com/users/cloudbeers/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/cloudbeers/yolo", + "description": "You only live once", + "fork": false, + "url": "https://api.github.com/repos/cloudbeers/yolo", + "forks_url": "https://api.github.com/repos/cloudbeers/yolo/forks", + "keys_url": "https://api.github.com/repos/cloudbeers/yolo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/cloudbeers/yolo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/cloudbeers/yolo/teams", + "hooks_url": "https://api.github.com/repos/cloudbeers/yolo/hooks", + "issue_events_url": "https://api.github.com/repos/cloudbeers/yolo/issues/events{/number}", + "events_url": "https://api.github.com/repos/cloudbeers/yolo/events", + "assignees_url": "https://api.github.com/repos/cloudbeers/yolo/assignees{/user}", + "branches_url": "https://api.github.com/repos/cloudbeers/yolo/branches{/branch}", + "tags_url": "https://api.github.com/repos/cloudbeers/yolo/tags", + "blobs_url": "https://api.github.com/repos/cloudbeers/yolo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/cloudbeers/yolo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/cloudbeers/yolo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/cloudbeers/yolo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/cloudbeers/yolo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/cloudbeers/yolo/languages", + "stargazers_url": "https://api.github.com/repos/cloudbeers/yolo/stargazers", + "contributors_url": "https://api.github.com/repos/cloudbeers/yolo/contributors", + "subscribers_url": "https://api.github.com/repos/cloudbeers/yolo/subscribers", + "subscription_url": "https://api.github.com/repos/cloudbeers/yolo/subscription", + "commits_url": "https://api.github.com/repos/cloudbeers/yolo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/cloudbeers/yolo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/cloudbeers/yolo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/cloudbeers/yolo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/cloudbeers/yolo/contents/{+path}", + "compare_url": "https://api.github.com/repos/cloudbeers/yolo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/cloudbeers/yolo/merges", + "archive_url": "https://api.github.com/repos/cloudbeers/yolo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/cloudbeers/yolo/downloads", + "issues_url": "https://api.github.com/repos/cloudbeers/yolo/issues{/number}", + "pulls_url": "https://api.github.com/repos/cloudbeers/yolo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/cloudbeers/yolo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/cloudbeers/yolo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/cloudbeers/yolo/labels{/name}", + "releases_url": "https://api.github.com/repos/cloudbeers/yolo/releases{/id}", + "deployments_url": "https://api.github.com/repos/cloudbeers/yolo/deployments", + "created_at": "2015-09-24T02:58:30Z", + "updated_at": "2016-12-07T23:55:35Z", + "pushed_at": "2016-12-01T16:07:01Z", + "git_url": "git://github.com/cloudbeers/yolo.git", + "ssh_url": "git@github.com:cloudbeers/yolo.git", + "clone_url": "https://github.com/cloudbeers/yolo.git", + "svn_url": "https://github.com/cloudbeers/yolo", + "homepage": "http://yolo.example.com", + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "archived": false, + "has_wiki": true, + "has_pages": false, + "forks_count": 3, + "mirror_url": null, + "open_issues_count": 1, + "forks": 3, + "open_issues": 1, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": false, + "push": false, + "pull": true + } +}, + { + "id": 43041241, + "name": "yolo-archived", + "full_name": "cloudbeers/yolo-archived", + "owner": { + "login": "cloudbeers", + "id": 4181899, + "avatar_url": "https://avatars.githubusercontent.com/u/4181899?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/cloudbeers", + "html_url": "https://github.com/cloudbeers", + "followers_url": "https://api.github.com/users/cloudbeers/followers", + "following_url": "https://api.github.com/users/cloudbeers/following{/other_user}", + "gists_url": "https://api.github.com/users/cloudbeers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/cloudbeers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/cloudbeers/subscriptions", + "organizations_url": "https://api.github.com/users/cloudbeers/orgs", + "repos_url": "https://api.github.com/users/cloudbeers/repos", + "events_url": "https://api.github.com/users/cloudbeers/events{/privacy}", + "received_events_url": "https://api.github.com/users/cloudbeers/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/cloudbeers/yolo-archived", + "description": "It lived once, and then it was archived", + "fork": false, + "url": "https://api.github.com/repos/cloudbeers/yolo-archived", + "forks_url": "https://api.github.com/repos/cloudbeers/yolo-archived/forks", + "keys_url": "https://api.github.com/repos/cloudbeers/yolo-archived/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/cloudbeers/yolo-archived/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/cloudbeers/yolo-archived/teams", + "hooks_url": "https://api.github.com/repos/cloudbeers/yolo-archived/hooks", + "issue_events_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues/events{/number}", + "events_url": "https://api.github.com/repos/cloudbeers/yolo-archived/events", + "assignees_url": "https://api.github.com/repos/cloudbeers/yolo-archived/assignees{/user}", + "branches_url": "https://api.github.com/repos/cloudbeers/yolo-archived/branches{/branch}", + "tags_url": "https://api.github.com/repos/cloudbeers/yolo-archived/tags", + "blobs_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/cloudbeers/yolo-archived/statuses/{sha}", + "languages_url": "https://api.github.com/repos/cloudbeers/yolo-archived/languages", + "stargazers_url": "https://api.github.com/repos/cloudbeers/yolo-archived/stargazers", + "contributors_url": "https://api.github.com/repos/cloudbeers/yolo-archived/contributors", + "subscribers_url": "https://api.github.com/repos/cloudbeers/yolo-archived/subscribers", + "subscription_url": "https://api.github.com/repos/cloudbeers/yolo-archived/subscription", + "commits_url": "https://api.github.com/repos/cloudbeers/yolo-archived/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/cloudbeers/yolo-archived/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/cloudbeers/yolo-archived/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/cloudbeers/yolo-archived/contents/{+path}", + "compare_url": "https://api.github.com/repos/cloudbeers/yolo-archived/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/cloudbeers/yolo-archived/merges", + "archive_url": "https://api.github.com/repos/cloudbeers/yolo-archived/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/cloudbeers/yolo-archived/downloads", + "issues_url": "https://api.github.com/repos/cloudbeers/yolo-archived/issues{/number}", + "pulls_url": "https://api.github.com/repos/cloudbeers/yolo-archived/pulls{/number}", + "milestones_url": "https://api.github.com/repos/cloudbeers/yolo-archived/milestones{/number}", + "notifications_url": "https://api.github.com/repos/cloudbeers/yolo-archived/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/cloudbeers/yolo-archived/labels{/name}", + "releases_url": "https://api.github.com/repos/cloudbeers/yolo-archived/releases{/id}", + "deployments_url": "https://api.github.com/repos/cloudbeers/yolo-archived/deployments", + "created_at": "2015-09-24T02:58:30Z", + "updated_at": "2016-12-07T23:55:35Z", + "pushed_at": "2016-12-01T16:07:01Z", + "git_url": "git://github.com/cloudbeers/yolo-archived.git", + "ssh_url": "git@github.com:cloudbeers/yolo-archived.git", + "clone_url": "https://github.com/cloudbeers/yolo-archived.git", + "svn_url": "https://github.com/cloudbeers/yolo-archived", + "homepage": "http://yolo-archived.example.com", + "size": 3, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "archived": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 3, + "mirror_url": null, + "open_issues_count": 1, + "forks": 3, + "open_issues": 1, + "watchers": 0, + "default_branch": "master", + "permissions": { + "admin": false, + "push": false, + "pull": true + } +} +] \ No newline at end of file diff --git a/src/test/resources/api/mappings/mapping-cloudbeers-yolo-archived.json b/src/test/resources/api/mappings/mapping-cloudbeers-yolo-archived.json new file mode 100644 index 000000000..cd6d3fb8d --- /dev/null +++ b/src/test/resources/api/mappings/mapping-cloudbeers-yolo-archived.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/repos/cloudbeers/yolo-archived", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "body-cloudbeers-yolo-archived.json", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 06 Dec 2016 15:06:25 GMT", + "Content-Type": "application/json; charset=utf-8", + "Transfer-Encoding": "chunked", + "Status": "200 OK", + "X-RateLimit-Limit": "600", + "X-RateLimit-Remaining": "600", + "X-RateLimit-Reset": "1481039662", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept", "Accept-Encoding"], + "ETag": "W/\"12cee9e1d9874cbabcbfaf3b112e8dac\"", + "Last-Modified": "Mon, 21 Nov 2016 22:53:53 GMT", + "X-GitHub-Media-Type": "github.v3; format=json", + "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin": "*", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-Served-By": "2d7a5e35115884240089368322196939", + "X-GitHub-Request-Id": "B2A7FE77:629C:AF96C44:5846D3F1" + } + } +} \ No newline at end of file diff --git a/src/test/resources/api/mappings/mapping-body-orgs-cloudbeers-repo-gUIDg.json b/src/test/resources/api/mappings/mapping-orgs-cloudbeers-repo-gUIDg.json similarity index 100% rename from src/test/resources/api/mappings/mapping-body-orgs-cloudbeers-repo-gUIDg.json rename to src/test/resources/api/mappings/mapping-orgs-cloudbeers-repo-gUIDg.json diff --git a/src/test/resources/api/mappings/mapping-rate_limit-B5BGx.json b/src/test/resources/api/mappings/mapping-rate_limit-B5BGx.json new file mode 100644 index 000000000..53921dba1 --- /dev/null +++ b/src/test/resources/api/mappings/mapping-rate_limit-B5BGx.json @@ -0,0 +1,31 @@ +{ + "id" : "858ec6db-837e-3829-80be-49b92a017610", + "request" : { + "url" : "/rate_limit", + "method" : "GET" + }, + "response" : { + "status" : 200, + "bodyFileName" : "body-rate_limit-B5BGx.json", + "headers" : { + "Date" : "Thu, 30 Jan 2020 17:42:15 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Server" : "GitHub.com", + "Status" : "200 OK", + "X-GitHub-Media-Type" : "github.v3; format=json", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4999", + "X-RateLimit-Reset": "1372700873", + "Access-Control-Expose-Headers" : "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin" : "*", + "Strict-Transport-Security" : "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options" : "deny", + "X-Content-Type-Options" : "nosniff", + "X-XSS-Protection" : "1; mode=block", + "Referrer-Policy" : "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy" : "default-src 'none'", + "X-GitHub-Request-Id" : "FB84:12584:80135A:98A539:5E331577" + } + }, + "uuid" : "858ec6db-837e-3829-80be-49b92a017610" +} \ No newline at end of file diff --git a/src/test/resources/api/mappings/mapping-stephenc-yolo-archived.json b/src/test/resources/api/mappings/mapping-stephenc-yolo-archived.json new file mode 100644 index 000000000..4236d99d1 --- /dev/null +++ b/src/test/resources/api/mappings/mapping-stephenc-yolo-archived.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/repos/stephenc/yolo-archived", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "body-stephenc-yolo-archived.json", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 06 Dec 2016 15:06:25 GMT", + "Content-Type": "application/json; charset=utf-8", + "Transfer-Encoding": "chunked", + "Status": "200 OK", + "X-RateLimit-Limit": "600", + "X-RateLimit-Remaining": "600", + "X-RateLimit-Reset": "1481039662", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept", "Accept-Encoding"], + "ETag": "W/\"12cee9e1d9874cbabcbfaf3b112e8dac\"", + "Last-Modified": "Mon, 21 Nov 2016 22:53:53 GMT", + "X-GitHub-Media-Type": "github.v3; format=json", + "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin": "*", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-Served-By": "2d7a5e35115884240089368322196939", + "X-GitHub-Request-Id": "B2A7FE77:629C:AF96C44:5846D3F1" + } + } +} \ No newline at end of file diff --git a/src/test/resources/api/mappings/mapping-user-JRfTU.json b/src/test/resources/api/mappings/mapping-user-JRfTU.json new file mode 100644 index 000000000..d6138b613 --- /dev/null +++ b/src/test/resources/api/mappings/mapping-user-JRfTU.json @@ -0,0 +1,34 @@ +{ + "request" : { + "url" : "/user", + "method" : "GET", + "basicAuth": { + "username": "git-user", + "password": "git-secret" + } + }, + "response" : { + "status" : 200, + "bodyFileName" : "body-users-stephenc-JRfTU.json", + "headers" : { + "Date" : "Thu, 30 Jan 2020 16:38:59 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Server" : "GitHub.com", + "Transfer-Encoding": "chunked", + "Status" : "200 OK", + "X-GitHub-Media-Type" : "github.v3; format=json", + "X-RateLimit-Limit" : "60", + "X-RateLimit-Remaining" : "51", + "X-RateLimit-Reset" : "1580403200", + "Access-Control-Expose-Headers" : "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin" : "*", + "Strict-Transport-Security" : "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options" : "deny", + "X-Content-Type-Options" : "nosniff", + "X-XSS-Protection" : "1; mode=block", + "Referrer-Policy" : "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy" : "default-src 'none'", + "X-GitHub-Request-Id" : "F6AC:12585:1435134:1835D1B:5E3306A3" + } + } +} \ No newline at end of file diff --git a/src/test/resources/api/mappings/mapping-user-repos-O8W78.json b/src/test/resources/api/mappings/mapping-user-repos-O8W78.json new file mode 100644 index 000000000..777aafc3e --- /dev/null +++ b/src/test/resources/api/mappings/mapping-user-repos-O8W78.json @@ -0,0 +1,35 @@ +{ + "id" : "ff960dbb-fe98-37d6-82ac-9f79ab7dd0de", + "request" : { + "urlPath" : "/user/repos", + "method" : "GET", + "basicAuth": { + "username": "git-user", + "password": "git-secret" + } + }, + "response" : { + "status" : 200, + "bodyFileName" : "body-user-repos-O8W78.json", + "headers" : { + "Date" : "Fri, 31 Jan 2020 10:49:58 GMT", + "Content-Type" : "application/json; charset=utf-8", + "Server" : "GitHub.com", + "Status" : "200 OK", + "X-GitHub-Media-Type" : "github.v3; format=json", + "X-RateLimit-Limit" : "60", + "X-RateLimit-Remaining" : "54", + "X-RateLimit-Reset" : "1580469786", + "Access-Control-Expose-Headers" : "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type", + "Access-Control-Allow-Origin" : "*", + "Strict-Transport-Security" : "max-age=31536000; includeSubdomains; preload", + "X-Frame-Options" : "deny", + "X-Content-Type-Options" : "nosniff", + "X-XSS-Protection" : "1; mode=block", + "Referrer-Policy" : "origin-when-cross-origin, strict-origin-when-cross-origin", + "Content-Security-Policy" : "default-src 'none'", + "X-GitHub-Request-Id" : "C1F9:C8CD:5FFC805:7325FB9:5E340656" + } + }, + "uuid" : "ff960dbb-fe98-37d6-82ac-9f79ab7dd0de" +} \ No newline at end of file diff --git a/src/test/resources/api/mappings/mapping-users-stephenc-repos.json b/src/test/resources/api/mappings/mapping-users-stephenc-repos.json new file mode 100644 index 000000000..6f80e163a --- /dev/null +++ b/src/test/resources/api/mappings/mapping-users-stephenc-repos.json @@ -0,0 +1,34 @@ +{ + "request": { + "url": "/users/stephenc/repos?per_page=100", + "method": "GET" + }, + "response": { + "status": 200, + "bodyFileName": "body-users-stephenc-repos.json", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 06 Dec 2016 15:06:25 GMT", + "Content-Type": "application/json; charset=utf-8", + "Transfer-Encoding": "chunked", + "Status": "200 OK", + "X-RateLimit-Limit": "600", + "X-RateLimit-Remaining": "600", + "X-RateLimit-Reset": "1481039662", + "Cache-Control": "public, max-age=60, s-maxage=60", + "Vary": ["Accept", "Accept-Encoding"], + "ETag": "W/\"91482e12d1cde431b38e0238d74dfa7b\"", + "Last-Modified": "Sat, 27 Feb 2016 07:57:23 GMT", + "X-GitHub-Media-Type": "github.v3; format=json", + "Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval", + "Access-Control-Allow-Origin": "*", + "Content-Security-Policy": "default-src 'none'", + "Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload", + "X-Content-Type-Options": "nosniff", + "X-Frame-Options": "deny", + "X-XSS-Protection": "1; mode=block", + "X-Served-By": "d256f86292c6dde5d09d15d926ec67a3", + "X-GitHub-Request-Id": "B2A7FE77:629C:AF96C1F:5846D3F0" + } + } +} From 70e681499f4ca21498079f8249f92b84febe9575 Mon Sep 17 00:00:00 2001 From: Karl Shultz Date: Fri, 31 Jan 2020 11:14:18 -0500 Subject: [PATCH 02/49] Drafts of CONTRIBUTING and PULL_REQUEST_TEMPLATE --- CONTRIBUTING.md | 106 +++++++++++++++++++++++++++++++++++++++ PULL_REQUEST_TEMPLATE.md | 19 +++++++ 2 files changed, 125 insertions(+) create mode 100644 CONTRIBUTING.md create mode 100644 PULL_REQUEST_TEMPLATE.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..5fc55f88e --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,106 @@ +# Contributing to GitHub Branch Source +Community pull requests are encouraged and welcomed! Following are some guidelines for what to expect. + +## Getting started +For information on contributing to Jenkins in general, check out the +[Beginner's Guide](https://wiki.jenkins-ci.org/display/JENKINS/Beginners+Guide+to+Contributing) to contributing to +Jenkins. Also, please make sure to read the [Jenkins Code of Conduct](https://jenkins.io/project/conduct/). The main +[jenkins.io website](https://jenkins.io/doc/developer) has lots of information about developing and extending Jenkins, +including several [how-to guides](https://jenkins.io/doc/developer/guides/) about plugin development. + +## Being careful + +GitHub Branch Source is one of the most widely used plugins in the Jenkins plugin catalog. +It is relied upon by hundreds of thousands of people worldwide. Because of this huge install +base, caution must be exercised when making changes. Code changes are reviewed +with a high level of scrutiny, out of necessity. This level of thoroughness should not be interpreted +as a personal attack. (And, of course, if it is a personal attack, that's why we have the +[Code of Conduct](https://jenkins.io/project/conduct/) in place). + +## How to submit your contribution + +Changes should come in the form of pull requests to the master branch of the main repository. Contributors +may do so from the origin repository, e.g. +`https://github.com/jenkinsci/github-branch-source-plugin`, or from their own fork, e.g. +`https://github.com/firstTimeContributor/github-branch-source-plugin`. + +Changes should never be made directly to master. This holds true for all contributions, +no matter the person or the change. Pull requests allow for easy code review. + +High-impact security patches may sometimes follow an accelerated process. The +[Jenkins Security team's process](https://jenkins.io/security/) describes how to report, and +work on, security vulnerabilities in Jenkins plugins. + +Any new functionality, API changes, or bug fixes must include adequate automated test coverage. +If you feel that your pull request does not need its own test coverage, state this in +the description, including the reason(s) why. + +Please use human-readable commit messages. When your code is being reviewed, a commit message like +`Add unit test for whizBang.getSomethingAwesome` is far more useful than `testcase`. + +If your PR relies on open PRs in other plugins, please include references to them in your +PR. This makes it easy for reviewers to navigate between all of the relevant PRs. + +## Associating changes with existing Jira issues + +If your PR is in response to an existing issue (bug, improvement, etc) in +[the Jenkins JIRA](https://issues.jenkins-ci.org/secure/Dashboard.jspa), include the issue +key in the subject line, with `[` `]` square brackets surrounding it. For example, +`[JENKINS-12345] Improve GitHub Branch Source with fluxCapacitor module`. This keeps the issue +easy to see in what can become a long list of PRs. + +## Creating a new Jira issue for your contribution + +When proposing new features or enhancements, potential contributors should file a Jira issue first, +describing their proposed changes and potential implementation details. Consensus can be reached in +the Jira issue before the PR is filed. This prevents surprising plugin maintainers, and prevents +contributors from having large amounts of work refused. + +Trivial changes might not warrant filing a Jira issue; although there is no harm in filing +one anyway. Larger changes, which have noticeable impact on your fellow users and developers, +should always have a Jira issue filed for them. This Jira issue serves as a centralized +location for discussion about the change. + +To give a sense of what constitutes a trivial change versus a larger one, here are some examples. +This is not intended to be an all-inclusive list, but it should give an idea: + +| Trivial Changes, no Jira needed | Larger Changes, file a Jira | +| --------------------------------|-------------------------------| +| Additional test coverage | Entirely new functionality | +| Spelling, Grammar, other typos | API Changes | +| Edits to inline help | New or updated dependencies | +| Cleaning up of unused imports | User Interface changes | + +## Testing your changes + +Before submitting your pull request, it needs to have been tested. This may take the form of +the automated tests you've included in your pull request - _you did include tests, right?_ +To run your tests locally, simply building the plugin via `mvn clean install` will run all +of its tests locally. + +Additionally, manual testing is welcomed and encouraged. If you've done some particularly clever +testing of your changes, please describe that in the description of your pull request, so that +your reviewers know what's already been done. + +Once submitted, your change will be built, and the plugin's tests will get run, on +[ci.jenkins.io](https://ci.jenkins.io). GitHub will be notified of the results of this build, +so you don't need to follow up and look for yourself. Your changes will be tested with combinations +of Java 8 and 11, on Linux and Windows. + +## The code review process + +We promise to be thoughtful, professional, and reasonable, and the same is expected of all +contributors. [Jenkins has a Code of Conduct](https://jenkins.io/project/conduct/), and we +take that seriously. We want the Jenkins community to be an open and welcoming one, for all +contributors, no matter how seasoned. + +In order to have your PR merged or considered for merging, you must respond to all actionable +feedback. + +## Merging and releasing + +The process by which pull requests get merged to master is fairly simple, and is described +in the [guide for releasing a plugin](https://jenkins.io/doc/developer/publishing/releasing/). +In short, once changes are merged to master, a release can be generated. Final decisions +on merging and releasing fall to the plugin's maintainer. + diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..5c6fc69e7 --- /dev/null +++ b/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,19 @@ +# Description + +A brief summary describing the changes in this pull request. See +[JENKINS-XXXXX](https://issues.jenkins-ci.org/browse/JENKINS-XXXXX) for further information. + + +# Submitter checklist +- [ ] Link to JIRA ticket in description, if appropriate. +- [ ] Change is code complete and matches issue description +- [ ] Automated tests have been added to exercise the changes +- [ ] Reviewer's manual test instructions provided in PR description. See Reviewer's first task below. + +# Reviewer checklist +- [ ] Run the changes and verify that the change matches the issue description +- [ ] Reviewed the code +- [ ] Verified that the appropriate tests have been written or valid explanation given + From 708d23ac18897494087c3f71c259919284cfe532 Mon Sep 17 00:00:00 2001 From: Karl Shultz Date: Fri, 31 Jan 2020 11:44:37 -0500 Subject: [PATCH 03/49] Move the PR template to .github --- .github/PULL_REQUEST_TEMPLATE.md | 27 +++++++++++++++++++-------- PULL_REQUEST_TEMPLATE.md | 19 ------------------- 2 files changed, 19 insertions(+), 27 deletions(-) delete mode 100644 PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index f5252cae5..5c6fc69e7 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,19 @@ -* JENKINS issue(s): - * Issue link or n/a -* Description: - * ... -* Documentation changes: - * Link to related jenkins.io PR or explanation for why doc change not needed -* Users/aliases to notify: - * ... +# Description + +A brief summary describing the changes in this pull request. See +[JENKINS-XXXXX](https://issues.jenkins-ci.org/browse/JENKINS-XXXXX) for further information. + + +# Submitter checklist +- [ ] Link to JIRA ticket in description, if appropriate. +- [ ] Change is code complete and matches issue description +- [ ] Automated tests have been added to exercise the changes +- [ ] Reviewer's manual test instructions provided in PR description. See Reviewer's first task below. + +# Reviewer checklist +- [ ] Run the changes and verify that the change matches the issue description +- [ ] Reviewed the code +- [ ] Verified that the appropriate tests have been written or valid explanation given + diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5c6fc69e7..000000000 --- a/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,19 +0,0 @@ -# Description - -A brief summary describing the changes in this pull request. See -[JENKINS-XXXXX](https://issues.jenkins-ci.org/browse/JENKINS-XXXXX) for further information. - - -# Submitter checklist -- [ ] Link to JIRA ticket in description, if appropriate. -- [ ] Change is code complete and matches issue description -- [ ] Automated tests have been added to exercise the changes -- [ ] Reviewer's manual test instructions provided in PR description. See Reviewer's first task below. - -# Reviewer checklist -- [ ] Run the changes and verify that the change matches the issue description -- [ ] Reviewed the code -- [ ] Verified that the appropriate tests have been written or valid explanation given - From 3ca1520f42864b2a234071df0c92f2f25f6e2a42 Mon Sep 17 00:00:00 2001 From: Karl Shultz Date: Fri, 31 Jan 2020 11:46:22 -0500 Subject: [PATCH 04/49] Moves CONTRIBUITNG to .github to override default org one --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md From 8a3929c91d815ec58654c70a6b9a8121840aa35d Mon Sep 17 00:00:00 2001 From: Nick Griffiths Date: Sat, 1 Feb 2020 14:10:24 +0000 Subject: [PATCH 05/49] Use "ExcludeArchivedRepositories" More descriptive that "ExcludeArchived". --- ...it.java => ExcludeArchivedRepositoriesTrait.java} | 12 ++++++------ .../github_branch_source/GitHubSCMNavigator.java | 12 ++++++------ .../GitHubSCMNavigatorContext.java | 12 ++++++------ .../plugins/github_branch_source/Messages.properties | 2 +- .../github_branch_source/GitHubSCMNavigatorTest.java | 12 ++++++------ 5 files changed, 25 insertions(+), 25 deletions(-) rename src/main/java/org/jenkinsci/plugins/github_branch_source/{ExcludeArchivedTrait.java => ExcludeArchivedRepositoriesTrait.java} (77%) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedRepositoriesTrait.java similarity index 77% rename from src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait.java rename to src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedRepositoriesTrait.java index af65d5013..9b446aaf9 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedTrait.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/ExcludeArchivedRepositoriesTrait.java @@ -13,13 +13,13 @@ /** * A {@link Selection} trait that will restrict the discovery of repositories that have been archived. */ -public class ExcludeArchivedTrait extends SCMNavigatorTrait { +public class ExcludeArchivedRepositoriesTrait extends SCMNavigatorTrait { /** * Constructor for stapler. */ @DataBoundConstructor - public ExcludeArchivedTrait() { + public ExcludeArchivedRepositoriesTrait() { } /** @@ -29,13 +29,13 @@ public ExcludeArchivedTrait() { protected void decorateContext(SCMNavigatorContext context) { super.decorateContext(context); GitHubSCMNavigatorContext ctx = (GitHubSCMNavigatorContext) context; - ctx.setExcludeArchived(true); + ctx.setExcludeArchivedRepositories(true); } /** - * Excluded archived repositories filter + * Exclude archived repositories filter */ - @Symbol("archivedRepositoriesFilter") + @Symbol("gitHubExcludeArchivedRepositories") @Extension @Selection public static class DescriptorImpl extends SCMNavigatorTraitDescriptor { @@ -48,7 +48,7 @@ public Class getContextClass() { @Nonnull @Override public String getDisplayName() { - return Messages.ExcludeArchivedTrait_displayName(); + return Messages.ExcludeArchivedRepositoriesTrait_displayName(); } } } diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index af4a41d1d..4b7e60d82 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -952,7 +952,7 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru continue; // ignore repos in other orgs when using GHMyself } - if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) { witness.record(repo.getName(), false); listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( @@ -987,7 +987,7 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru for (GHRepository repo : repositories) { Connector.checkApiRateLimit(listener, github); - if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) { witness.record(repo.getName(), false); listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( @@ -1018,7 +1018,7 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru for (GHRepository repo : user.listRepositories(100)) { Connector.checkApiRateLimit(listener, github); - if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) { witness.record(repo.getName(), false); listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( @@ -1116,7 +1116,7 @@ public void visitSource(String sourceName, SCMSourceObserver observer) GHRepository repo = myself.getRepository(sourceName); if (repo != null && repo.getOwnerName().equals(repoOwner)) { - if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) { witness.record(repo.getName(), false); listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( @@ -1146,7 +1146,7 @@ public void visitSource(String sourceName, SCMSourceObserver observer) GHRepository repo = org.getRepository(sourceName); if (repo != null) { - if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) { witness.record(repo.getName(), false); listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( @@ -1178,7 +1178,7 @@ public void visitSource(String sourceName, SCMSourceObserver observer) GHRepository repo = user.getRepository(sourceName); if (repo != null) { - if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchived()) { + if (repo.isArchived() && gitHubSCMNavigatorContext.isExcludeArchivedRepositories()) { witness.record(repo.getName(), false); listener.getLogger() .println(GitHubConsoleNote.create(System.currentTimeMillis(), String.format( diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorContext.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorContext.java index a864e7523..478203aad 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorContext.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorContext.java @@ -43,7 +43,7 @@ public class GitHubSCMNavigatorContext extends SCMNavigatorContext projectNames = new HashSet<>(); final SCMSourceObserver observer = getObserver(projectNames); @@ -232,7 +232,7 @@ public void fetchOneRepo_BelongingToOrg() throws Exception { @Test public void fetchOneRepo_BelongingToOrg_ExcludingArchived() throws Exception { - navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedRepositoriesTrait())); final Set projectNames = new HashSet<>(); final SCMSourceObserver observer = getObserver(projectNames); @@ -255,7 +255,7 @@ public void fetchOneRepo_BelongingToUser() throws Exception { @Test public void fetchOneRepo_BelongingToUser_ExcludingArchived() throws Exception { navigator = navigatorForRepoOwner("stephenc", null); - navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedRepositoriesTrait())); final Set projectNames = new HashSet<>(); final SCMSourceObserver observer = getObserver(projectNames); @@ -280,7 +280,7 @@ public void fetchRepos_BelongingToAuthenticatedUser() throws Exception { public void fetchRepos_BelongingToAuthenticatedUser_ExcludingArchived() throws Exception { setCredentials(Collections.singletonList(credentials)); navigator = navigatorForRepoOwner("stephenc", credentials.getId()); - navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedRepositoriesTrait())); final Set projectNames = new HashSet<>(); final SCMSourceObserver observer = getObserver(projectNames); @@ -302,7 +302,7 @@ public void fetchRepos_BelongingToOrg() throws Exception { @Test public void fetchRepos_BelongingToOrg_ExcludingArchived() throws Exception { - navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedRepositoriesTrait())); final Set projectNames = new HashSet<>(); final SCMSourceObserver observer = getObserver(projectNames); @@ -326,7 +326,7 @@ public void fetchRepos_BelongingToUser() throws Exception { @Test public void fetchRepos_BelongingToUser_ExcludingArchived() throws Exception { navigator = navigatorForRepoOwner("stephenc", null); - navigator.setTraits(Collections.singletonList(new ExcludeArchivedTrait())); + navigator.setTraits(Collections.singletonList(new ExcludeArchivedRepositoriesTrait())); final Set projectNames = new HashSet<>(); final SCMSourceObserver observer = getObserver(projectNames); From 9a69bb38bd12b69e2802f1de6a992f66245d054a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Sun, 2 Feb 2020 11:30:05 +0100 Subject: [PATCH 06/49] Improve help texts - wording - formatting - consistency --- .../help-strategyId.html | 6 ++--- .../help-credentialsId.html | 6 ++--- .../GitHubSCMSource/help-credentialsId.html | 6 ++--- .../GitHubSCMSource/help-repositoryUrl.html | 22 +++++++++++++------ .../help-strategyId.html | 6 ++--- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait/help-strategyId.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait/help-strategyId.html index e8db8435a..0600c53a7 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait/help-strategyId.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait/help-strategyId.html @@ -3,16 +3,16 @@
Merging the pull request with the current target branch revision
Discover each pull request once with the discovered revision corresponding to the result of merging with the - current revision of the target branch + current revision of the target branch.
The current pull request revision
Discover each pull request once with the discovered revision corresponding to the pull request head revision - without merging + without merging.
Both the current pull request revision and the pull request merged with the current target branch revision
Discover each pull request twice. The first discovered revision corresponds to the result of merging with the current revision of the target branch in each scan. The second parallel discovered revision corresponds - to the pull request head revision without merging + to the pull request head revision without merging.
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html index 91b423287..a77b93fbd 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html @@ -5,8 +5,8 @@

Note that only "username with password" credentials are supported. - Existing credentials of other kinds will be filtered out. This is because jenkins - exercises GitHub API, and this last one does not support other ways of authentication. + Existing credentials of other kinds will be filtered out. This is because Jenkins + uses the GitHub API, which does not support other ways of authentication.

If none is given, only the public repositories will be scanned, and commit status @@ -14,7 +14,7 @@

If your organization contains private repositories, then you need to specify - a credential from an user who have access to those repositories. This is done + a credential from a user who has access to those repositories. This is done by creating a "username with password" credential where the password is GitHub personal access tokens. The necessary scope is "repo". diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html index 91b423287..a77b93fbd 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html @@ -5,8 +5,8 @@

Note that only "username with password" credentials are supported. - Existing credentials of other kinds will be filtered out. This is because jenkins - exercises GitHub API, and this last one does not support other ways of authentication. + Existing credentials of other kinds will be filtered out. This is because Jenkins + uses the GitHub API, which does not support other ways of authentication.

If none is given, only the public repositories will be scanned, and commit status @@ -14,7 +14,7 @@

If your organization contains private repositories, then you need to specify - a credential from an user who have access to those repositories. This is done + a credential from a user who has access to those repositories. This is done by creating a "username with password" credential where the password is GitHub personal access tokens. The necessary scope is "repo". diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-repositoryUrl.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-repositoryUrl.html index c0436084c..53a0322b4 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-repositoryUrl.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-repositoryUrl.html @@ -1,9 +1,17 @@

-

Specify the HTTPS URL of the GitHub Organization/User and repository.

-

Github examples:

-

https://github.com/jenkinsci/github-branch-source-plugin

-

https://github.com/jenkinsci/github-branch-source-plugin.git

-

Github Enterprise examples:

-

https://myccompany.github.com/jenkinsci/github-branch-source-plugin

-

https://myccompany.github.com/jenkinsci/github-branch-source-plugin.git

+

Specify the HTTPS URL of the GitHub Organization / User Account and repository.

+

+ GitHub examples: +

    +
  • https://github.com/jenkinsci/github-branch-source-plugin
  • +
  • https://github.com/jenkinsci/github-branch-source-plugin.git
  • +
+

+

+ GitHub Enterprise examples: +

    +
  • https://myccompany.github.com/jenkinsci/github-branch-source-plugin
  • +
  • https://myccompany.github.com/jenkinsci/github-branch-source-plugin.git
  • +
+

diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTrait/help-strategyId.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTrait/help-strategyId.html index e8db8435a..0600c53a7 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTrait/help-strategyId.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTrait/help-strategyId.html @@ -3,16 +3,16 @@
Merging the pull request with the current target branch revision
Discover each pull request once with the discovered revision corresponding to the result of merging with the - current revision of the target branch + current revision of the target branch.
The current pull request revision
Discover each pull request once with the discovered revision corresponding to the pull request head revision - without merging + without merging.
Both the current pull request revision and the pull request merged with the current target branch revision
Discover each pull request twice. The first discovered revision corresponds to the result of merging with the current revision of the target branch in each scan. The second parallel discovered revision corresponds - to the pull request head revision without merging + to the pull request head revision without merging.
From dd3d0c950b4730135696ff123aca0bcbac97b4b3 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 3 Feb 2020 12:24:30 -0800 Subject: [PATCH 07/49] Move to release 2.6.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 75ee51b84..a70e64569 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ - 2.5.9 + 2.6.0 -SNAPSHOT 2.2.0 8 From 2cf5718fd44d8486fb049360c480a82ce65b0d77 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 3 Feb 2020 12:34:05 -0800 Subject: [PATCH 08/49] [maven-release-plugin] prepare release github-branch-source-2.6.0 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index a70e64569..41bb2c795 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ github-branch-source - ${revision}${changelist} + 2.6.0 hpi GitHub Branch Source Plugin https://github.com/jenkinsci/${project.artifactId}-plugin @@ -36,7 +36,7 @@ scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git https://github.com/jenkinsci/${project.artifactId}-plugin - ${scmTag} + github-branch-source-2.6.0 From 30caec7f5326a58d1bdfa13d36c3f6e4533cb4a9 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 3 Feb 2020 12:34:19 -0800 Subject: [PATCH 09/49] [maven-release-plugin] prepare for next development iteration --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 41bb2c795..dbbab0a0f 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ github-branch-source - 2.6.0 + ${revision}${changelist} hpi GitHub Branch Source Plugin https://github.com/jenkinsci/${project.artifactId}-plugin @@ -21,7 +21,7 @@ - 2.6.0 + 2.6.1 -SNAPSHOT 2.2.0 8 @@ -36,7 +36,7 @@ scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git https://github.com/jenkinsci/${project.artifactId}-plugin - github-branch-source-2.6.0 + ${scmTag} From e1a15b0ff32d317e04364ec2f6ee2ab1adceb234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 22:05:18 +0100 Subject: [PATCH 10/49] Improve Javascript code - add missing semicolons - consistent formatting - explicit variable declaration --- src/main/webapp/github-scm-source.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/webapp/github-scm-source.js b/src/main/webapp/github-scm-source.js index 9e3893d10..1025f39a0 100644 --- a/src/main/webapp/github-scm-source.js +++ b/src/main/webapp/github-scm-source.js @@ -15,35 +15,35 @@ Behaviour.specify("input[name$=_configuredByUrlRadio]", 'GitHubSCMSourceRadioCon } } return e; - } + }; // Todo: Replace with a query selector? var findNeighboringDynamicInput = function(e) { var inputTbody = getNthParent(e, 4 /*tbody > tr > td > label > input*/); if (inputTbody) { // input hidden is always in the 4th position - var hiddenBlock = inputTbody.childNodes[4].firstElementChild.firstElementChild + var hiddenBlock = inputTbody.childNodes[4].firstElementChild.firstElementChild; return hiddenBlock } - } + }; var neighboringDynamicInput = findNeighboringDynamicInput(e); if (neighboringDynamicInput) { e.onclick = function() { neighboringDynamicInput.value = e.value; // When changing to true the event is triggered. - if(e.value == "false"){ + if (e.value == "false") { // When changing to false a trigger has to be fired in order to fetch the repos from the backend if (document.createEvent) { - oEvent = document.createEvent("HTMLEvents"); + var oEvent = document.createEvent("HTMLEvents"); oEvent.initEvent("change"); // Gets the first Jelly entry afte the hidden value - var repoOwner = getNthParent(e, 3).nextElementSibling.nextElementSibling.childNodes[2].firstElementChild + var repoOwner = getNthParent(e, 3).nextElementSibling.nextElementSibling.childNodes[2].firstElementChild; // if the first entry is a select for API URI, gets the following one (each Jelly entry has 3 elements) - if (repoOwner == null || repoOwner.tagName == "SELECT"){ - repoOwner = getNthParent(e, 3).nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.childNodes[2].firstElementChild + if (repoOwner == null || repoOwner.tagName == "SELECT") { + repoOwner = getNthParent(e, 3).nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.nextElementSibling.childNodes[2].firstElementChild; } - if( repoOwner != null) { + if (repoOwner != null) { // fire a onchange event on the repoOwner input test to get the repos from backend repoOwner.dispatchEvent(oEvent); } From f511d7c45e0a1ad1c33bbbe61a95199c515f6988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 23:26:41 +0100 Subject: [PATCH 11/49] Remove redundant type arguments They can be inferred by the compiler. --- .../GitHubConfiguration.java | 4 +- .../GitHubSCMSourceContext.java | 2 +- .../GitHubSCMSourceRequest.java | 8 +- .../PushGHEventSubscriber.java | 6 +- .../ForkPullRequestDiscoveryTrait2Test.java | 2 +- .../ForkPullRequestDiscoveryTraitTest.java | 12 +- .../GitHubNotificationTest.java | 10 +- .../GitHubSCMBuilderTest.java | 5 +- .../GitHubSCMNavigatorTest.java | 8 +- .../GitHubSCMNavigatorTraitsTest.java | 442 +++++++++--------- .../GitHubSCMSourceTest.java | 16 +- .../GitHubSCMSourceTraitsTest.java | 388 +++++++-------- .../OriginPullRequestDiscoveryTraitTest.java | 10 +- 13 files changed, 452 insertions(+), 461 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConfiguration.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConfiguration.java index 8ac058bb7..74db1d6a9 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConfiguration.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConfiguration.java @@ -63,7 +63,7 @@ public GitHubConfiguration() { @NonNull public synchronized List getEndpoints() { - return endpoints == null ? Collections.emptyList() : Collections.unmodifiableList(endpoints); + return endpoints == null ? Collections.emptyList() : Collections.unmodifiableList(endpoints); } @NonNull @@ -122,7 +122,7 @@ public static String normalizeApiUri(@CheckForNull String apiUri) { } public synchronized void setEndpoints(@CheckForNull List endpoints) { - endpoints = new ArrayList(endpoints == null ? Collections.emptyList() : endpoints); + endpoints = new ArrayList(endpoints == null ? Collections.emptyList() : endpoints); // remove duplicates and empty urls Set apiUris = new HashSet(); for (Iterator iterator = endpoints.iterator(); iterator.hasNext(); ) { diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceContext.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceContext.java index 2f4c7c532..9f251cf35 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceContext.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceContext.java @@ -165,7 +165,7 @@ public final Set forkPRStrategies() { */ public final List notificationStrategies() { if (notificationStrategies.isEmpty()) { - return Collections.singletonList(new DefaultGitHubNotificationStrategy()); + return Collections.singletonList(new DefaultGitHubNotificationStrategy()); } return Collections.unmodifiableList(notificationStrategies); } diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java index 0f615f017..20a9aec58 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java @@ -153,10 +153,10 @@ public class GitHubSCMSourceRequest extends SCMSourceRequest { fetchForkPRs = context.wantForkPRs(); originPRStrategies = fetchOriginPRs && !context.originPRStrategies().isEmpty() ? Collections.unmodifiableSet(EnumSet.copyOf(context.originPRStrategies())) - : Collections.emptySet(); + : Collections.emptySet(); forkPRStrategies = fetchForkPRs && !context.forkPRStrategies().isEmpty() ? Collections.unmodifiableSet(EnumSet.copyOf(context.forkPRStrategies())) - : Collections.emptySet(); + : Collections.emptySet(); Set includes = context.observer().getIncludes(); if (includes != null) { Set pullRequestNumbers = new HashSet<>(includes.size()); @@ -258,9 +258,9 @@ public final Set getForkPRStrategies() { @NonNull public final Set getPRStrategies(boolean fork) { if (fork) { - return fetchForkPRs ? getForkPRStrategies() : Collections.emptySet(); + return fetchForkPRs ? getForkPRStrategies() : Collections.emptySet(); } - return fetchOriginPRs ? getOriginPRStrategies() : Collections.emptySet(); + return fetchOriginPRs ? getOriginPRStrategies() : Collections.emptySet(); } /** diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java index d2d32dc0a..d88144700 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java @@ -319,8 +319,7 @@ && isApiMatch(((GitHubSCMSource) source).getApiUri()) } } if (!excluded) { - return Collections.singletonMap(head, - new AbstractGitSCMSource.SCMRevisionImpl(head, push.getHead())); + return Collections.singletonMap(head, new AbstractGitSCMSource.SCMRevisionImpl(head, push.getHead())); } } if (context.wantTags() && ref.startsWith(R_TAGS)) { @@ -352,8 +351,7 @@ && isApiMatch(((GitHubSCMSource) source).getApiUri()) } } if (!excluded) { - return Collections.singletonMap(head, - new GitTagSCMRevision(head, push.getHead())); + return Collections.singletonMap(head, new GitTagSCMRevision(head, push.getHead())); } } return Collections.emptyMap(); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java index c03fa0bc5..b6681bf2c 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java @@ -74,7 +74,7 @@ private void assertRoundTrip(WorkflowMultiBranchProject p, SCMHeadAuthoritysingletonList(new ForkPullRequestDiscoveryTrait(0, trust))); + s.setTraits(Collections.singletonList(new ForkPullRequestDiscoveryTrait(0, trust))); r.configRoundtrip(p); List traits = ((GitHubSCMSource) p.getSourcesList().get(0).getSource()).getTraits(); assertEquals(1, traits.size()); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java index 8a91615c3..14a92c506 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java @@ -44,8 +44,7 @@ public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCor assertThat(ctx.wantPRs(), is(true)); assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); - assertThat(ctx.forkPRStrategies(), - Matchers.>is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); + assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); assertThat(ctx.authorities(), (Matcher) hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) )); @@ -70,8 +69,7 @@ public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorr assertThat(ctx.wantPRs(), is(true)); assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); - assertThat(ctx.forkPRStrategies(), - Matchers.>is(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD))); + assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD))); assertThat(ctx.authorities(), (Matcher) hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) )); @@ -96,8 +94,7 @@ public void given__disoverMergeOnly__when__appliedToContext__then__strategiesCor assertThat(ctx.wantPRs(), is(true)); assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); - assertThat(ctx.forkPRStrategies(), - Matchers.>is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))); + assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))); assertThat(ctx.authorities(), (Matcher) hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) )); @@ -122,8 +119,7 @@ public void given__nonDefaultTrust__when__appliedToContext__then__authoritiesCor assertThat(ctx.wantPRs(), is(true)); assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); - assertThat(ctx.forkPRStrategies(), - Matchers.>is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); + assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); assertThat(ctx.authorities(), (Matcher) hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustEveryone.class) )); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationTest.java index f42276e9e..03f9c023c 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationTest.java @@ -59,7 +59,7 @@ public void given__defaultNotificationStrategy__when__appliedToContext__then__du public void given__emptyStrategiesList__when__appliedToContext__then__defaultApplied() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.notificationStrategies().size(), is(1)); - ctx.withNotificationStrategies(Collections.emptyList()); + ctx.withNotificationStrategies(Collections.emptyList()); assertThat(ctx.notificationStrategies().size(), is(1)); } @@ -67,7 +67,7 @@ public void given__emptyStrategiesList__when__appliedToContext__then__defaultApp public void given__defaultStrategy__when__emptyStrategyList__then__strategyAdded() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.notificationStrategies().size(), is(1)); - ctx.withNotificationStrategies(Collections.emptyList()); + ctx.withNotificationStrategies(Collections.emptyList()); assertThat(ctx.notificationStrategies().size(), is(1)); ctx.withNotificationStrategy(new DefaultGitHubNotificationStrategy()); assertThat(ctx.notificationStrategies().size(), is(1)); @@ -77,9 +77,9 @@ public void given__defaultStrategy__when__emptyStrategyList__then__strategyAdded public void given__defaultStrategyList__when__emptyStrategyList__then__strategyAdded() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.notificationStrategies().size(), is(1)); - ctx.withNotificationStrategies(Collections.emptyList()); + ctx.withNotificationStrategies(Collections.emptyList()); assertThat(ctx.notificationStrategies().size(), is(1)); - ctx.withNotificationStrategies(Collections.singletonList(new DefaultGitHubNotificationStrategy())); + ctx.withNotificationStrategies(Collections.singletonList(new DefaultGitHubNotificationStrategy())); assertThat(ctx.notificationStrategies().size(), is(1)); } @@ -90,7 +90,7 @@ public void given__customStrategy__when__emptyStrategyList__then__noDefaultStrat ctx.withNotificationStrategy(new TestNotificationStrategy()); List strategies = ctx.notificationStrategies(); assertThat(strategies.size(), is(1)); - assertThat(strategies.get(0), Matchers.instanceOf(TestNotificationStrategy.class)); + assertThat(strategies.get(0), Matchers.instanceOf(TestNotificationStrategy.class)); } private final class TestNotificationStrategy extends AbstractGitHubNotificationStrategy { diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java index fa5c0a98a..9d9d9b754 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java @@ -90,13 +90,12 @@ public void setUp() throws IOException { Credentials sshPrivateKeyCredential = new BasicSSHUserPrivateKey(CredentialsScope.GLOBAL, "user-key", "git", new BasicSSHUserPrivateKey.UsersPrivateKeySource(), null, null); SystemCredentialsProvider.getInstance().setDomainCredentialsMap(Collections.singletonMap(Domain.global(), - Arrays.asList(userPasswordCredential, sshPrivateKeyCredential))); + Arrays.asList(userPasswordCredential, sshPrivateKeyCredential))); } @After public void tearDown() throws IOException, InterruptedException { - SystemCredentialsProvider.getInstance() - .setDomainCredentialsMap(Collections.>emptyMap()); + SystemCredentialsProvider.getInstance().setDomainCredentialsMap(Collections.emptyMap()); owner.delete(); } diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java index 9ffbe5570..645b7a08f 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java @@ -347,12 +347,12 @@ public void appliesFilters() throws Exception { @Test public void fetchActions() throws Exception { - assertThat(navigator.fetchActions(Mockito.mock(SCMNavigatorOwner.class), null, null), Matchers.containsInAnyOrder( - Matchers.is( + assertThat(navigator.fetchActions(Mockito.mock(SCMNavigatorOwner.class), null, null), Matchers.containsInAnyOrder( + Matchers.is( new ObjectMetadataAction("CloudBeers, Inc.", null, "https://github.com/cloudbeers") ), - Matchers.is(new GitHubOrgMetadataAction("https://avatars.githubusercontent.com/u/4181899?v=3")), - Matchers.is(new GitHubLink("icon-github-logo", "https://github.com/cloudbeers")))); + Matchers.is(new GitHubOrgMetadataAction("https://avatars.githubusercontent.com/u/4181899?v=3")), + Matchers.is(new GitHubLink("icon-github-logo", "https://github.com/cloudbeers")))); } @Test diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTraitsTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTraitsTest.java index 807c7b228..fbd0ee050 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTraitsTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTraitsTest.java @@ -69,16 +69,16 @@ public void basic_cloud() throws Exception { not(hasItem(Matchers.>instanceOf(RegexSCMSourceFilterTrait.class)))); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) @@ -113,21 +113,21 @@ public void basic_server() throws Exception { not(hasItem(Matchers.>instanceOf(RegexSCMSourceFilterTrait.class)))); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.>allOf( + Matchers.allOf( Matchers.instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is("8b2e4f77-39c5-41a9-b63b-8d367350bfdf")) ) @@ -161,21 +161,21 @@ public void use_agent_checkout() throws Exception { not(hasItem(Matchers.>instanceOf(RegexSCMSourceFilterTrait.class)))); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.>allOf( + Matchers.allOf( Matchers.instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is(nullValue())) ) @@ -212,16 +212,16 @@ public void same_checkout_credentials() throws Exception { not(hasItem(Matchers.>instanceOf(RegexSCMSourceFilterTrait.class)))); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) @@ -253,25 +253,25 @@ public void limit_repositories() throws Exception { ); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.>allOf( + Matchers.allOf( Matchers.instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is("8b2e4f77-39c5-41a9-b63b-8d367350bfdf")) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(RegexSCMSourceFilterTrait.class), hasProperty("regex", is("limited.*")) ) @@ -294,21 +294,21 @@ public void exclude_branches() throws Exception { assertThat(instance.getCredentialsId(), is("bcaef157-f105-407f-b150-df7722eab6c1")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("master")) @@ -331,21 +331,21 @@ public void limit_branches() throws Exception { assertThat(instance.getCredentialsId(), is("bcaef157-f105-407f-b150-df7722eab6c1")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -372,7 +372,7 @@ public void build_000001() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -385,7 +385,7 @@ public void build_000010() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -398,7 +398,7 @@ public void build_000011() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -411,7 +411,7 @@ public void build_000100() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -424,11 +424,11 @@ public void build_000101() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -441,11 +441,11 @@ public void build_000110() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -458,11 +458,11 @@ public void build_000111() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -475,7 +475,7 @@ public void build_001000() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -488,11 +488,11 @@ public void build_001001() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -505,11 +505,11 @@ public void build_001010() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -522,11 +522,11 @@ public void build_001011() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -539,7 +539,7 @@ public void build_001100() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -552,11 +552,11 @@ public void build_001101() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -569,11 +569,11 @@ public void build_001110() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -586,11 +586,11 @@ public void build_001111() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -603,7 +603,7 @@ public void build_010000() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) @@ -617,12 +617,12 @@ public void build_010001() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -635,12 +635,12 @@ public void build_010010() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -653,12 +653,12 @@ public void build_010011() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -671,12 +671,12 @@ public void build_010100() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -689,16 +689,16 @@ public void build_010101() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -711,16 +711,16 @@ public void build_010110() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -733,16 +733,16 @@ public void build_010111() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -755,12 +755,12 @@ public void build_011000() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -773,16 +773,16 @@ public void build_011001() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -795,16 +795,16 @@ public void build_011010() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -817,16 +817,16 @@ public void build_011011() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -839,12 +839,12 @@ public void build_011100() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -857,16 +857,16 @@ public void build_011101() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -879,16 +879,16 @@ public void build_011110() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -901,16 +901,16 @@ public void build_011111() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -923,7 +923,7 @@ public void build_100000() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) @@ -937,12 +937,12 @@ public void build_100001() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -955,12 +955,12 @@ public void build_100010() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -973,12 +973,12 @@ public void build_100011() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -991,12 +991,12 @@ public void build_100100() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1009,16 +1009,16 @@ public void build_100101() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1031,16 +1031,16 @@ public void build_100110() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1053,16 +1053,16 @@ public void build_100111() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1075,12 +1075,12 @@ public void build_101000() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1093,16 +1093,16 @@ public void build_101001() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1115,16 +1115,16 @@ public void build_101010() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1137,16 +1137,16 @@ public void build_101011() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1159,12 +1159,12 @@ public void build_101100() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1177,16 +1177,16 @@ public void build_101101() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1199,16 +1199,16 @@ public void build_101110() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1221,16 +1221,16 @@ public void build_101111() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1243,7 +1243,7 @@ public void build_110000() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), contains( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) @@ -1257,12 +1257,12 @@ public void build_110001() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1275,12 +1275,12 @@ public void build_110010() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1293,12 +1293,12 @@ public void build_110011() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1311,12 +1311,12 @@ public void build_110100() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1329,16 +1329,16 @@ public void build_110101() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1351,16 +1351,16 @@ public void build_110110() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1373,16 +1373,16 @@ public void build_110111() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1395,12 +1395,12 @@ public void build_111000() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1413,16 +1413,16 @@ public void build_111001() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1435,16 +1435,16 @@ public void build_111010() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1457,16 +1457,16 @@ public void build_111011() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1479,12 +1479,12 @@ public void build_111100() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1497,16 +1497,16 @@ public void build_111101() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1519,16 +1519,16 @@ public void build_111110() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1541,16 +1541,16 @@ public void build_111111() throws Exception { GitHubSCMNavigator instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1572,12 +1572,12 @@ public void given__legacyCode__when__constructor_cloud__then__discoveryTraitDefa assertThat(instance.getCredentialsId(), is("bcaef157-f105-407f-b150-df7722eab6c1")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategies", is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) @@ -1605,17 +1605,17 @@ public void given__legacyCode__when__constructor_server__then__discoveryTraitDef assertThat(instance.getCredentialsId(), is("bcaef157-f105-407f-b150-df7722eab6c1")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategies", is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.>allOf( + Matchers.allOf( Matchers.instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is("8b2e4f77-39c5-41a9-b63b-8d367350bfdf")) ) @@ -1638,16 +1638,16 @@ public void given__instance__when__setTraits_empty__then__traitsEmpty() { @Test public void given__instance__when__setTraits__then__traitsSet() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList(new BranchDiscoveryTrait(1), + instance.setTraits(Arrays.asList(new BranchDiscoveryTrait(1), new SSHCheckoutTrait(null))); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.>allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.>allOf( + Matchers.allOf( instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is(nullValue())) ) @@ -1700,14 +1700,14 @@ public void given__instance__when__setApiUri_cloudUrl__then__valueApplied() { @Test public void given__legacyCode__when__setPattern_default__then__patternSetAndTraitRemoved() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList(new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), + instance.setTraits(Arrays.asList(new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new SSHCheckoutTrait("dummy"))); assertThat(instance.getPattern(), is("job.*")); - assertThat(instance.getTraits(), Matchers.>hasItem(instanceOf(RegexSCMSourceFilterTrait.class))); + assertThat(instance.getTraits(), Matchers.hasItem(instanceOf(RegexSCMSourceFilterTrait.class))); instance.setPattern(".*"); assertThat(instance.getPattern(), is(".*")); assertThat(instance.getTraits(), - not(Matchers.>hasItem(instanceOf(RegexSCMSourceFilterTrait.class)))); + not(Matchers.hasItem(instanceOf(RegexSCMSourceFilterTrait.class)))); } @@ -1715,13 +1715,13 @@ public void given__legacyCode__when__setPattern_default__then__patternSetAndTrai public void given__legacyCode__when__setPattern_custom__then__patternSetAndTraitAdded() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); instance.setTraits( - Arrays.>>asList(new BranchDiscoveryTrait(true, false), new SSHCheckoutTrait("dummy"))); + Arrays.asList(new BranchDiscoveryTrait(true, false), new SSHCheckoutTrait("dummy"))); assertThat(instance.getPattern(), is(".*")); assertThat(instance.getTraits(), - not(Matchers.>hasItem(instanceOf(RegexSCMSourceFilterTrait.class)))); + not(Matchers.hasItem(instanceOf(RegexSCMSourceFilterTrait.class)))); instance.setPattern("job.*"); assertThat(instance.getPattern(), is("job.*")); - assertThat(instance.getTraits(), Matchers.>hasItem( + assertThat(instance.getTraits(), Matchers.hasItem( allOf(instanceOf(RegexSCMSourceFilterTrait.class), hasProperty("regex", is("job.*"))))); } @@ -1732,12 +1732,12 @@ public void given__legacyCode__when__setPattern_custom__then__patternSetAndTrait instance.setTraits(new SCMTrait[]{new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new SSHCheckoutTrait("dummy")}); assertThat(instance.getPattern(), is("job.*")); - assertThat(instance.getTraits(), Matchers.>hasItem(instanceOf(RegexSCMSourceFilterTrait.class))); + assertThat(instance.getTraits(), Matchers.hasItem(instanceOf(RegexSCMSourceFilterTrait.class))); instance.setPattern("project.*"); assertThat(instance.getPattern(), is("project.*")); - assertThat(instance.getTraits(), not(Matchers.>hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( allOf(instanceOf(RegexSCMSourceFilterTrait.class), hasProperty("regex", is("job.*")))))); - assertThat(instance.getTraits(), Matchers.>hasItem( + assertThat(instance.getTraits(), Matchers.hasItem( allOf(instanceOf(RegexSCMSourceFilterTrait.class), hasProperty("regex", is("project.*"))))); } @@ -1746,14 +1746,14 @@ public void given__legacyCode__when__setPattern_custom__then__patternSetAndTrait public void given__legacyCode__when__checkoutCredentials_SAME__then__noTraitAdded() { GitHubSCMNavigator instance = new GitHubSCMNavigator(null, "test", "scan", GitHubSCMSource.DescriptorImpl.SAME); assertThat(instance.getCheckoutCredentialsId(), is(GitHubSCMNavigator.DescriptorImpl.SAME)); - assertThat(instance.getTraits(), not(Matchers.>hasItem(instanceOf(SSHCheckoutTrait.class)))); + assertThat(instance.getTraits(), not(Matchers.hasItem(instanceOf(SSHCheckoutTrait.class)))); } @Test public void given__legacyCode__when__checkoutCredentials_null__then__traitAdded_ANONYMOUS() { GitHubSCMNavigator instance = new GitHubSCMNavigator(null, "test", "scan", null); assertThat(instance.getCheckoutCredentialsId(), is(GitHubSCMSource.DescriptorImpl.ANONYMOUS)); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is(nullValue())) ))); @@ -1763,7 +1763,7 @@ public void given__legacyCode__when__checkoutCredentials_null__then__traitAdded_ public void given__legacyCode__when__checkoutCredentials_value__then__traitAdded() { GitHubSCMNavigator instance = new GitHubSCMNavigator(null, "test", "scan", "value"); assertThat(instance.getCheckoutCredentialsId(), is("value")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is("value")) ))); @@ -1774,7 +1774,7 @@ public void given__legacyCode__when__checkoutCredentials_ANONYMOUS__then__traitA GitHubSCMNavigator instance = new GitHubSCMNavigator(null, "test", "scan", GitHubSCMSource.DescriptorImpl.ANONYMOUS); assertThat(instance.getCheckoutCredentialsId(), is(GitHubSCMSource.DescriptorImpl.ANONYMOUS)); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is(nullValue())) ))); @@ -1783,14 +1783,14 @@ public void given__legacyCode__when__checkoutCredentials_ANONYMOUS__then__traitA @Test public void given__legacyCode_withoutExcludes__when__setIncludes_default__then__traitRemoved() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList( + instance.setTraits(Arrays.asList( new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new WildcardSCMHeadFilterTrait("feature/*", "") )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -1798,7 +1798,7 @@ public void given__legacyCode_withoutExcludes__when__setIncludes_default__then__ instance.setIncludes("*"); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), not(Matchers.>hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( instanceOf(WildcardSCMHeadFilterTrait.class) ))); } @@ -1813,7 +1813,7 @@ public void given__legacyCode_withoutExcludes__when__setIncludes_value__then__tr }); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -1821,7 +1821,7 @@ public void given__legacyCode_withoutExcludes__when__setIncludes_value__then__tr instance.setIncludes("bug/*"); assertThat(instance.getIncludes(), is("bug/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("bug/*")), hasProperty("excludes", is("")) @@ -1831,19 +1831,19 @@ public void given__legacyCode_withoutExcludes__when__setIncludes_value__then__tr @Test public void given__legacyCode_withoutTrait__when__setIncludes_value__then__traitAdded() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList( + instance.setTraits(Arrays.asList( new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*") )); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), not(Matchers.>hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( instanceOf(WildcardSCMHeadFilterTrait.class) ))); instance.setIncludes("feature/*"); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -1853,14 +1853,14 @@ public void given__legacyCode_withoutTrait__when__setIncludes_value__then__trait @Test public void given__legacyCode_withExcludes__when__setIncludes_default__then__traitUpdated() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList( + instance.setTraits(Arrays.asList( new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new WildcardSCMHeadFilterTrait("feature/*", "feature/ignore") )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) @@ -1868,7 +1868,7 @@ public void given__legacyCode_withExcludes__when__setIncludes_default__then__tra instance.setIncludes("*"); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("feature/ignore")) @@ -1885,7 +1885,7 @@ public void given__legacyCode_withExcludes__when__setIncludes_value__then__trait }); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) @@ -1893,7 +1893,7 @@ public void given__legacyCode_withExcludes__when__setIncludes_value__then__trait instance.setIncludes("bug/*"); assertThat(instance.getIncludes(), is("bug/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("bug/*")), hasProperty("excludes", is("feature/ignore")) @@ -1903,14 +1903,14 @@ public void given__legacyCode_withExcludes__when__setIncludes_value__then__trait @Test public void given__legacyCode_withoutIncludes__when__setExcludes_default__then__traitRemoved() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList( + instance.setTraits(Arrays.asList( new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new WildcardSCMHeadFilterTrait("*", "feature/ignore") )); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("feature/ignore")) @@ -1918,7 +1918,7 @@ public void given__legacyCode_withoutIncludes__when__setExcludes_default__then__ instance.setExcludes(""); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), not(Matchers.>hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( instanceOf(WildcardSCMHeadFilterTrait.class) ))); } @@ -1926,14 +1926,14 @@ public void given__legacyCode_withoutIncludes__when__setExcludes_default__then__ @Test public void given__legacyCode_withoutIncludes__when__setExcludes_value__then__traitUpdated() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList( + instance.setTraits(Arrays.asList( new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new WildcardSCMHeadFilterTrait("*", "feature/ignore") )); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("feature/ignore")) @@ -1941,7 +1941,7 @@ public void given__legacyCode_withoutIncludes__when__setExcludes_value__then__tr instance.setExcludes("bug/ignore"); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("bug/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("bug/ignore")) @@ -1951,19 +1951,19 @@ public void given__legacyCode_withoutIncludes__when__setExcludes_value__then__tr @Test public void given__legacyCode_withoutTrait__when__setExcludes_value__then__traitAdded() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList( + instance.setTraits(Arrays.asList( new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*") )); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), not(Matchers.>hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( instanceOf(WildcardSCMHeadFilterTrait.class) ))); instance.setExcludes("feature/ignore"); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("feature/ignore")) @@ -1973,14 +1973,14 @@ public void given__legacyCode_withoutTrait__when__setExcludes_value__then__trait @Test public void given__legacyCode_withIncludes__when__setExcludes_default__then__traitUpdated() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList( + instance.setTraits(Arrays.asList( new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new WildcardSCMHeadFilterTrait("feature/*", "feature/ignore") )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) @@ -1988,7 +1988,7 @@ public void given__legacyCode_withIncludes__when__setExcludes_default__then__tra instance.setExcludes(""); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -1998,14 +1998,14 @@ public void given__legacyCode_withIncludes__when__setExcludes_default__then__tra @Test public void given__legacyCode_withIncludes__when__setExcludes_value__then__traitUpdated() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Arrays.>>asList( + instance.setTraits(Arrays.asList( new BranchDiscoveryTrait(true, false), new RegexSCMSourceFilterTrait("job.*"), new WildcardSCMHeadFilterTrait("feature/*", "") )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -2013,7 +2013,7 @@ public void given__legacyCode_withIncludes__when__setExcludes_value__then__trait instance.setExcludes("feature/ignore"); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.>hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) @@ -2023,7 +2023,7 @@ public void given__legacyCode_withIncludes__when__setExcludes_value__then__trait @Test public void given__legacyCode__when__setBuildOriginBranch__then__traitsMaintained() { GitHubSCMNavigator instance = new GitHubSCMNavigator("test"); - instance.setTraits(Collections.>>emptyList()); + instance.setTraits(Collections.emptyList()); assertThat(instance.getTraits(), is(Collections.>emptyList())); instance.setBuildOriginBranch(true); assertThat(instance.getTraits(), contains(instanceOf(BranchDiscoveryTrait.class))); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java index 29d2e9ba3..643192790 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java @@ -163,11 +163,11 @@ public void testGitHubRepositoryNameContributor_When_not_GitHub() throws IOExcep WorkflowMultiBranchProject job = r.createProject(WorkflowMultiBranchProject.class); job.setSourcesList(Arrays.asList(new BranchSource(new GitSCMSource("file://tmp/something")))); Collection names = GitHubRepositoryNameContributor.parseAssociatedNames(job); - assertThat(names, Matchers.empty()); + assertThat(names, Matchers.empty()); //And specifically... names = new ArrayList<>(); ExtensionList.lookup(GitHubRepositoryNameContributor.class).get(GitHubSCMSourceRepositoryNameContributor.class).parseAssociatedNames(job, names); - assertThat(names, Matchers.empty()); + assertThat(names, Matchers.empty()); } @Test @@ -175,11 +175,11 @@ public void testGitHubRepositoryNameContributor_When_not_GitHub() throws IOExcep public void testGitHubRepositoryNameContributor_When_not_MultiBranch() throws IOException { FreeStyleProject job = r.createProject(FreeStyleProject.class); Collection names = GitHubRepositoryNameContributor.parseAssociatedNames((Item) job); - assertThat(names, Matchers.empty()); + assertThat(names, Matchers.empty()); //And specifically... names = new ArrayList<>(); ExtensionList.lookup(GitHubRepositoryNameContributor.class).get(GitHubSCMSourceRepositoryNameContributor.class).parseAssociatedNames((Item) job, names); - assertThat(names, Matchers.empty()); + assertThat(names, Matchers.empty()); } @Test @@ -634,15 +634,15 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro @Test public void fetchActions() throws Exception { - assertThat(source.fetchActions(null, null), Matchers.containsInAnyOrder( - Matchers.is( + assertThat(source.fetchActions(null, null), Matchers.containsInAnyOrder( + Matchers.is( new ObjectMetadataAction(null, "You only live once", "http://yolo.example.com") ), - Matchers.is( + Matchers.is( new GitHubDefaultBranch("cloudbeers", "yolo", "master") ), instanceOf(GitHubRepoMetadataAction.class), - Matchers.is(new GitHubLink("icon-github-repo", "https://github.com/cloudbeers/yolo")))); + Matchers.is(new GitHubLink("icon-github-repo", "https://github.com/cloudbeers/yolo")))); } @Test diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java index 9471d613c..cde36937c 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTraitsTest.java @@ -146,12 +146,12 @@ public void basic_cloud() throws Exception { assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) @@ -183,16 +183,16 @@ public void basic_server() throws Exception { assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) @@ -224,21 +224,21 @@ public void custom_checkout_credentials() throws Exception { assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.allOf( + Matchers.allOf( Matchers.instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is("other-credentials")) ) @@ -270,16 +270,16 @@ public void same_checkout_credentials() throws Exception { assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) @@ -311,17 +311,17 @@ public void exclude_branches() throws Exception { assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("master")) @@ -353,17 +353,17 @@ public void limit_branches() throws Exception { assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -395,17 +395,17 @@ public void use_agent_checkout() throws Exception { assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.allOf( + Matchers.allOf( Matchers.instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is(nullValue())) ) @@ -434,12 +434,12 @@ public void given__legacyCode__when__constructor_cloud__then__discoveryTraitDefa assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategies", is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) @@ -470,17 +470,17 @@ public void given__legacyCode__when__constructor_server__then__discoveryTraitDef assertThat(instance.getCredentialsId(), is("e4d8c11a-0d24-472f-b86b-4b017c160e9a")); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategies", is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))), hasProperty("trust", instanceOf(ForkPullRequestDiscoveryTrait.TrustPermission.class)) ), - Matchers.allOf( + Matchers.allOf( Matchers.instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is("8b2e4f77-39c5-41a9-b63b-8d367350bfdf")) ) @@ -501,14 +501,14 @@ public void given__legacyCode__when__constructor_server__then__discoveryTraitDef @Test public void given__instance__when__setTraits_empty__then__traitsEmpty() { GitHubSCMSource instance = new GitHubSCMSource("testing", "test-repo"); - instance.setTraits(Collections.emptyList()); + instance.setTraits(Collections.emptyList()); assertThat(instance.getTraits(), is(Collections.emptyList())); } @Test public void given__legacyCode__when__setBuildOriginBranch__then__traitsMaintained() { GitHubSCMSource instance = new GitHubSCMSource("testing", "test-repo"); - instance.setTraits(Collections.emptyList()); + instance.setTraits(Collections.emptyList()); assertThat(instance.getTraits(), is(Collections.emptyList())); instance.setBuildOriginBranch(true); assertThat(instance.getTraits(), contains(instanceOf(BranchDiscoveryTrait.class))); @@ -544,12 +544,12 @@ public void given__instance__when__setTraits__then__traitsSet() { new SSHCheckoutTrait("value"))); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(SSHCheckoutTrait.class), hasProperty("credentialsId", is("value")) ) @@ -597,7 +597,7 @@ public void given__legacyCode_withoutExcludes__when__setIncludes_default__then__ )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -605,7 +605,7 @@ public void given__legacyCode_withoutExcludes__when__setIncludes_default__then__ instance.setIncludes("*"); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), not(Matchers.hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( instanceOf(WildcardSCMHeadFilterTrait.class) ))); } @@ -619,7 +619,7 @@ public void given__legacyCode_withoutExcludes__when__setIncludes_value__then__tr )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -627,7 +627,7 @@ public void given__legacyCode_withoutExcludes__when__setIncludes_value__then__tr instance.setIncludes("bug/*"); assertThat(instance.getIncludes(), is("bug/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("bug/*")), hasProperty("excludes", is("")) @@ -643,13 +643,13 @@ public void given__legacyCode_withoutTrait__when__setIncludes_value__then__trait )); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), not(Matchers.hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( instanceOf(WildcardSCMHeadFilterTrait.class) ))); instance.setIncludes("feature/*"); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -666,7 +666,7 @@ public void given__legacyCode_withExcludes__when__setIncludes_default__then__tra )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) @@ -674,7 +674,7 @@ public void given__legacyCode_withExcludes__when__setIncludes_default__then__tra instance.setIncludes("*"); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("feature/ignore")) @@ -691,7 +691,7 @@ public void given__legacyCode_withExcludes__when__setIncludes_value__then__trait )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) @@ -699,7 +699,7 @@ public void given__legacyCode_withExcludes__when__setIncludes_value__then__trait instance.setIncludes("bug/*"); assertThat(instance.getIncludes(), is("bug/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("bug/*")), hasProperty("excludes", is("feature/ignore")) @@ -716,7 +716,7 @@ public void given__legacyCode_withoutIncludes__when__setExcludes_default__then__ )); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("feature/ignore")) @@ -724,7 +724,7 @@ public void given__legacyCode_withoutIncludes__when__setExcludes_default__then__ instance.setExcludes(""); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), not(Matchers.hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( instanceOf(WildcardSCMHeadFilterTrait.class) ))); } @@ -739,7 +739,7 @@ public void given__legacyCode_withoutIncludes__when__setExcludes_value__then__tr )); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("feature/ignore")) @@ -747,7 +747,7 @@ public void given__legacyCode_withoutIncludes__when__setExcludes_value__then__tr instance.setExcludes("bug/ignore"); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("bug/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("bug/ignore")) @@ -763,13 +763,13 @@ public void given__legacyCode_withoutTrait__when__setExcludes_value__then__trait )); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), not(Matchers.hasItem( + assertThat(instance.getTraits(), not(Matchers.hasItem( instanceOf(WildcardSCMHeadFilterTrait.class) ))); instance.setExcludes("feature/ignore"); assertThat(instance.getIncludes(), is("*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("*")), hasProperty("excludes", is("feature/ignore")) @@ -786,7 +786,7 @@ public void given__legacyCode_withIncludes__when__setExcludes_default__then__tra )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) @@ -794,7 +794,7 @@ public void given__legacyCode_withIncludes__when__setExcludes_default__then__tra instance.setExcludes(""); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -811,7 +811,7 @@ public void given__legacyCode_withIncludes__when__setExcludes_value__then__trait )); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("")) @@ -819,7 +819,7 @@ public void given__legacyCode_withIncludes__when__setExcludes_value__then__trait instance.setExcludes("feature/ignore"); assertThat(instance.getIncludes(), is("feature/*")); assertThat(instance.getExcludes(), is("feature/ignore")); - assertThat(instance.getTraits(), Matchers.hasItem(allOf( + assertThat(instance.getTraits(), Matchers.hasItem(allOf( instanceOf(WildcardSCMHeadFilterTrait.class), hasProperty("includes", is("feature/*")), hasProperty("excludes", is("feature/ignore")) @@ -839,7 +839,7 @@ public void build_000001() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -852,7 +852,7 @@ public void build_000010() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -865,7 +865,7 @@ public void build_000011() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -878,7 +878,7 @@ public void build_000100() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -891,11 +891,11 @@ public void build_000101() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -908,11 +908,11 @@ public void build_000110() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -925,11 +925,11 @@ public void build_000111() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -942,7 +942,7 @@ public void build_001000() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -955,11 +955,11 @@ public void build_001001() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -972,11 +972,11 @@ public void build_001010() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -989,11 +989,11 @@ public void build_001011() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1006,7 +1006,7 @@ public void build_001100() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1019,11 +1019,11 @@ public void build_001101() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1036,11 +1036,11 @@ public void build_001110() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1053,11 +1053,11 @@ public void build_001111() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1070,7 +1070,7 @@ public void build_010000() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) @@ -1084,12 +1084,12 @@ public void build_010001() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1102,12 +1102,12 @@ public void build_010010() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1120,12 +1120,12 @@ public void build_010011() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1138,12 +1138,12 @@ public void build_010100() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1156,16 +1156,16 @@ public void build_010101() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1178,16 +1178,16 @@ public void build_010110() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1200,16 +1200,16 @@ public void build_010111() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1222,12 +1222,12 @@ public void build_011000() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1240,16 +1240,16 @@ public void build_011001() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1262,16 +1262,16 @@ public void build_011010() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1284,16 +1284,16 @@ public void build_011011() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1306,12 +1306,12 @@ public void build_011100() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1324,16 +1324,16 @@ public void build_011101() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1346,16 +1346,16 @@ public void build_011110() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1368,16 +1368,16 @@ public void build_011111() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(false)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1390,7 +1390,7 @@ public void build_100000() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) @@ -1404,12 +1404,12 @@ public void build_100001() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1422,12 +1422,12 @@ public void build_100010() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1440,12 +1440,12 @@ public void build_100011() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1458,12 +1458,12 @@ public void build_100100() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1476,16 +1476,16 @@ public void build_100101() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1498,16 +1498,16 @@ public void build_100110() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1520,16 +1520,16 @@ public void build_100111() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1542,12 +1542,12 @@ public void build_101000() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1560,16 +1560,16 @@ public void build_101001() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1582,16 +1582,16 @@ public void build_101010() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1604,16 +1604,16 @@ public void build_101011() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1626,12 +1626,12 @@ public void build_101100() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1644,16 +1644,16 @@ public void build_101101() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1666,16 +1666,16 @@ public void build_101110() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1688,16 +1688,16 @@ public void build_101111() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(false)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1710,7 +1710,7 @@ public void build_110000() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), contains( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) @@ -1724,12 +1724,12 @@ public void build_110001() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1742,12 +1742,12 @@ public void build_110010() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1760,12 +1760,12 @@ public void build_110011() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1778,12 +1778,12 @@ public void build_110100() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1796,16 +1796,16 @@ public void build_110101() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1818,16 +1818,16 @@ public void build_110110() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1840,16 +1840,16 @@ public void build_110111() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1862,12 +1862,12 @@ public void build_111000() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1880,16 +1880,16 @@ public void build_111001() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1902,16 +1902,16 @@ public void build_111010() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -1924,16 +1924,16 @@ public void build_111011() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1946,12 +1946,12 @@ public void build_111100() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) @@ -1964,16 +1964,16 @@ public void build_111101() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(2)) ) @@ -1986,16 +1986,16 @@ public void build_111110() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(1)) ) @@ -2008,16 +2008,16 @@ public void build_111111() throws Exception { GitHubSCMSource instance = load(); assertThat(instance.getTraits(), containsInAnyOrder( - Matchers.allOf( + Matchers.allOf( instanceOf(BranchDiscoveryTrait.class), hasProperty("buildBranch", is(true)), hasProperty("buildBranchesWithPR", is(true)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(OriginPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ), - Matchers.allOf( + Matchers.allOf( instanceOf(ForkPullRequestDiscoveryTrait.class), hasProperty("strategyId", is(3)) ) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java index 3bd404735..1ee1ac115 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java @@ -37,8 +37,7 @@ public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCor assertThat(ctx.wantPRs(), is(true)); assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); - assertThat(ctx.originPRStrategies(), - Matchers.>is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); + assertThat(ctx.originPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); assertThat(ctx.authorities(), (Matcher) hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) )); @@ -62,8 +61,7 @@ public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorr assertThat(ctx.wantPRs(), is(true)); assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); - assertThat(ctx.originPRStrategies(), - Matchers.>is(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD))); + assertThat(ctx.originPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD))); assertThat(ctx.authorities(), (Matcher) hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) )); @@ -88,7 +86,7 @@ public void given__disoverMergeOnly__when__appliedToContext__then__strategiesCor assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.originPRStrategies(), - Matchers.>is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))); + Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))); assertThat(ctx.authorities(), (Matcher) hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) )); @@ -112,7 +110,7 @@ public void given__programmaticConstructor__when__appliedToContext__then__strate assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.originPRStrategies(), - Matchers.>is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); + Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); assertThat(ctx.authorities(), (Matcher) hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) )); From 05de986edf0e696b21dac10dc62fba94dfcfa1ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 23:30:13 +0100 Subject: [PATCH 12/49] Remove redundant type casts They are not required. --- .../GitHubSCMNavigator.java | 2 +- .../BranchDiscoveryTraitTest.java | 6 +- .../ForkPullRequestDiscoveryTraitTest.java | 8 +- .../GitHubSCMBuilderTest.java | 132 +++++++++--------- .../GitHubSCMSourceTest.java | 22 +-- .../OriginPullRequestDiscoveryTraitTest.java | 8 +- 6 files changed, 89 insertions(+), 89 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 4b7e60d82..e4b2e1ea3 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -1352,7 +1352,7 @@ public String getIconClassName() { @Override public SCMNavigator newInstance(String name) { GitHubSCMNavigator navigator = new GitHubSCMNavigator(name); - navigator.setTraits((List) getTraitsDefaults()); + navigator.setTraits(getTraitsDefaults()); return navigator; } diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java index 1d82581d4..0343fbe18 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java @@ -38,7 +38,7 @@ public void given__disoverAll__when__appliedToContext__then__noFilter() throws E assertThat(ctx.wantPRs(), is(false)); assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class) )); } @@ -60,7 +60,7 @@ public void given__excludingPRs__when__appliedToContext__then__filter() throws E assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), contains(instanceOf(BranchDiscoveryTrait.ExcludeOriginPRBranchesSCMHeadFilter.class))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class) )); } @@ -81,7 +81,7 @@ public void given__onlyPRs__when__appliedToContext__then__filter() throws Except assertThat(ctx.wantPRs(), is(true)); assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), contains(instanceOf(BranchDiscoveryTrait.OnlyOriginPRBranchesSCMHeadFilter.class))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class) )); } diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java index 14a92c506..8579947eb 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java @@ -45,7 +45,7 @@ public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCor assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) )); } @@ -70,7 +70,7 @@ public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorr assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) )); } @@ -95,7 +95,7 @@ public void given__disoverMergeOnly__when__appliedToContext__then__strategiesCor assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) )); } @@ -120,7 +120,7 @@ public void given__nonDefaultTrust__when__appliedToContext__then__authoritiesCor assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.forkPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustEveryone.class) )); } diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java index 9d9d9b754..207552a90 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java @@ -108,8 +108,8 @@ public void given__cloud_branch_rev_anon__when__build__then__scmBuilt() throws E source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -162,8 +162,8 @@ public void given__cloud_branch_rev_userpass__when__build__then__scmBuilt() thro source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -216,8 +216,8 @@ public void given__cloud_branch_rev_userkey__when__build__then__scmBuilt() throw source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -270,8 +270,8 @@ public void given__cloud_branch_rev_anon_sshtrait_anon__when__build__then__scmBu source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -331,8 +331,8 @@ public void given__cloud_branch_rev_userpass_sshtrait_anon__when__build__then__s source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -391,8 +391,8 @@ public void given__cloud_branch_rev_userkey_sshtrait_anon__when__build__then__sc source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -451,8 +451,8 @@ public void given__cloud_branch_rev_anon_sshtrait_userkey__when__build__then__sc source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -511,8 +511,8 @@ public void given__cloud_branch_rev_userpass_sshtrait_userkey__when__build__then source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -571,8 +571,8 @@ public void given__cloud_branch_rev_userkey_sshtrait_userkey__when__build__then_ source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -629,7 +629,7 @@ public void given__cloud_branch_norev_anon__when__build__then__scmBuilt() throws source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", @@ -669,7 +669,7 @@ public void given__cloud_branch_norev_userpass__when__build__then__scmBuilt() th source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", @@ -709,7 +709,7 @@ public void given__cloud_branch_norev_userkey__when__build__then__scmBuilt() thr source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", @@ -751,8 +751,8 @@ public void given__server_branch_rev_anon__when__build__then__scmBuilt() throws source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -806,8 +806,8 @@ public void given__server_branch_rev_userpass__when__build__then__scmBuilt() thr source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -860,8 +860,8 @@ public void given__server_branch_rev_userkey__when__build__then__scmBuilt() thro source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -912,7 +912,7 @@ public void given__server_branch_norev_anon__when__build__then__scmBuilt() throw source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", @@ -952,7 +952,7 @@ public void given__server_branch_norev_userpass__when__build__then__scmBuilt() t source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", @@ -992,7 +992,7 @@ public void given__server_branch_norev_userkey__when__build__then__scmBuilt() th source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/heads/test-branch:refs/remotes/@{remote}/test-branch")); assertThat("expecting guess value until withGitHubRemote called", @@ -1039,8 +1039,8 @@ public void given__cloud_pullHead_rev_anon__when__build__then__scmBuilt() throws source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -1098,8 +1098,8 @@ public void given__cloud_pullHead_rev_userpass__when__build__then__scmBuilt() th source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -1157,8 +1157,8 @@ public void given__cloud_pullHead_rev_userkey__when__build__then__scmBuilt() thr source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -1211,7 +1211,7 @@ public void given__cloud_pullHead_norev_anon__when__build__then__scmBuilt() thro source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -1253,7 +1253,7 @@ public void given__cloud_pullHead_norev_userpass__when__build__then__scmBuilt() source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -1295,7 +1295,7 @@ public void given__cloud_pullHead_norev_userkey__when__build__then__scmBuilt() t source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -1342,8 +1342,8 @@ public void given__server_pullHead_rev_anon__when__build__then__scmBuilt() throw source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -1402,8 +1402,8 @@ public void given__server_pullHead_rev_userpass__when__build__then__scmBuilt() t source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -1461,8 +1461,8 @@ public void given__server_pullHead_rev_userkey__when__build__then__scmBuilt() th source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -1515,7 +1515,7 @@ public void given__server_pullHead_norev_anon__when__build__then__scmBuilt() thr source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -1557,7 +1557,7 @@ public void given__server_pullHead_norev_userpass__when__build__then__scmBuilt() source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -1599,7 +1599,7 @@ public void given__server_pullHead_norev_userkey__when__build__then__scmBuilt() source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -1646,8 +1646,8 @@ public void given__cloud_pullMerge_rev_anon__when__build__then__scmBuilt() throw source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -1716,8 +1716,8 @@ public void given__cloud_pullMerge_rev_userpass__when__build__then__scmBuilt() t source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -1786,8 +1786,8 @@ public void given__cloud_pullMerge_rev_userkey__when__build__then__scmBuilt() th source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.com/tester/test-repo.git")); @@ -1851,7 +1851,7 @@ public void given__cloud_pullMerge_norev_anon__when__build__then__scmBuilt() thr source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -1904,7 +1904,7 @@ public void given__cloud_pullMerge_norev_userpass__when__build__then__scmBuilt() source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -1957,7 +1957,7 @@ public void given__cloud_pullMerge_norev_userkey__when__build__then__scmBuilt() source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -2015,8 +2015,8 @@ public void given__server_pullMerge_rev_anon__when__build__then__scmBuilt() thro source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -2086,8 +2086,8 @@ public void given__server_pullMerge_rev_userpass__when__build__then__scmBuilt() source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -2156,8 +2156,8 @@ public void given__server_pullMerge_rev_userkey__when__build__then__scmBuilt() t source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, revision); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); - assertThat(instance.revision(), is((SCMRevision) revision)); + assertThat(instance.head(), is(head)); + assertThat(instance.revision(), is(revision)); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", instance.remote(), is("https://github.test/tester/test-repo.git")); @@ -2221,7 +2221,7 @@ public void given__server_pullMerge_norev_anon__when__build__then__scmBuilt() th source.setCredentialsId(null); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is(nullValue())); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -2275,7 +2275,7 @@ public void given__server_pullMerge_norev_userpass__when__build__then__scmBuilt( source.setCredentialsId("user-pass"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-pass")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", @@ -2329,7 +2329,7 @@ public void given__server_pullMerge_norev_userkey__when__build__then__scmBuilt() source.setCredentialsId("user-key"); GitHubSCMBuilder instance = new GitHubSCMBuilder(source, head, null); assertThat(instance.credentialsId(), is("user-key")); - assertThat(instance.head(), is((SCMHead) head)); + assertThat(instance.head(), is(head)); assertThat(instance.revision(), is(nullValue())); assertThat(instance.refSpecs(), contains("+refs/pull/1/head:refs/remotes/@{remote}/PR-1")); assertThat("expecting guess value until withGitHubRemote called", diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java index 643192790..fb446a148 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java @@ -201,7 +201,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-2"), instanceOf(PullRequestSCMHead.class)); assertThat(((PullRequestSCMHead)byName.get("PR-2")).isMerge(), is(true)); - assertThat(revByName.get("PR-2"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-2")), + assertThat(revByName.get("PR-2"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-2")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1", "38814ca33833ff5583624c29f305be9133f27a40" @@ -211,7 +211,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-3"), instanceOf(PullRequestSCMHead.class)); assertThat(((SCMHeadOrigin.Fork) byName.get("PR-3").getOrigin()).getName(), is("stephenc")); assertThat(((PullRequestSCMHead)byName.get("PR-3")).isMerge(), is(true)); - assertThat(revByName.get("PR-3"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), + assertThat(revByName.get("PR-3"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1", PullRequestSCMRevision.NOT_MERGEABLE_HASH @@ -274,7 +274,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-2"), instanceOf(PullRequestSCMHead.class)); assertThat(((PullRequestSCMHead)byName.get("PR-2")).isMerge(), is(true)); - assertThat(revByName.get("PR-2"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-2")), + assertThat(revByName.get("PR-2"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-2")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1", null @@ -284,7 +284,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-3"), instanceOf(PullRequestSCMHead.class)); assertThat(((PullRequestSCMHead)byName.get("PR-3")).isMerge(), is(true)); assertThat(((SCMHeadOrigin.Fork) byName.get("PR-3").getOrigin()).getName(), is("stephenc")); - assertThat(revByName.get("PR-3"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), + assertThat(revByName.get("PR-3"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1", PullRequestSCMRevision.NOT_MERGEABLE_HASH @@ -354,7 +354,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-3"), instanceOf(PullRequestSCMHead.class)); assertThat(((SCMHeadOrigin.Fork) byName.get("PR-3").getOrigin()).getName(), is("stephenc")); assertThat(((PullRequestSCMHead)byName.get("PR-3")).isMerge(), is(true)); - assertThat(revByName.get("PR-3"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), + assertThat(revByName.get("PR-3"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1", PullRequestSCMRevision.NOT_MERGEABLE_HASH @@ -444,7 +444,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-3"), instanceOf(PullRequestSCMHead.class)); assertThat(((SCMHeadOrigin.Fork) byName.get("PR-3").getOrigin()).getName(), is("stephenc")); assertThat(((PullRequestSCMHead)byName.get("PR-3")).isMerge(), is(true)); - assertThat(revByName.get("PR-3"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), + assertThat(revByName.get("PR-3"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1", PullRequestSCMRevision.NOT_MERGEABLE_HASH @@ -503,7 +503,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-2"), instanceOf(PullRequestSCMHead.class)); assertThat(((PullRequestSCMHead)byName.get("PR-2")).isMerge(), is(true)); - assertThat(revByName.get("PR-2"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-2")), + assertThat(revByName.get("PR-2"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-2")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1", null @@ -513,7 +513,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-3"), instanceOf(PullRequestSCMHead.class)); assertThat(((SCMHeadOrigin.Fork) byName.get("PR-3").getOrigin()).getName(), is("stephenc")); assertThat(((PullRequestSCMHead)byName.get("PR-3")).isMerge(), is(true)); - assertThat(revByName.get("PR-3"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), + assertThat(revByName.get("PR-3"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1", PullRequestSCMRevision.NOT_MERGEABLE_HASH @@ -605,7 +605,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.keySet(), containsInAnyOrder("PR-2", "PR-3", "PR-4", "master", "stephenc-patch-1")); assertThat(byName.get("PR-2"), instanceOf(PullRequestSCMHead.class)); assertThat(((PullRequestSCMHead)byName.get("PR-2")).isMerge(), is(false)); - assertThat(revByName.get("PR-2"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-2")), + assertThat(revByName.get("PR-2"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-2")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1" ))); @@ -614,7 +614,7 @@ public boolean isHead(@NonNull Probe probe, @NonNull TaskListener listener) thro assertThat(byName.get("PR-3"), instanceOf(PullRequestSCMHead.class)); assertThat(((SCMHeadOrigin.Fork) byName.get("PR-3").getOrigin()).getName(), is("stephenc")); assertThat(((PullRequestSCMHead)byName.get("PR-3")).isMerge(), is(false)); - assertThat(revByName.get("PR-3"), is((SCMRevision) new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), + assertThat(revByName.get("PR-3"), is(new PullRequestSCMRevision((PullRequestSCMHead)(byName.get("PR-3")), "8f1314fc3c8284d8c6d5886d473db98f2126071c", "c0e024f89969b976da165eecaa71e09dc60c3da1" ))); @@ -649,7 +649,7 @@ public void fetchActions() throws Exception { public void getTrustedRevisionReturnsRevisionIfRepoOwnerAndPullRequestBranchOwnerAreSameWithDifferentCase() throws Exception { source.setBuildOriginPRHead(true); PullRequestSCMRevision revision = createRevision("CloudBeers"); - assertThat(source.getTrustedRevision(revision, new LogTaskListener(Logger.getAnonymousLogger(), Level.INFO)), sameInstance((SCMRevision) revision)); + assertThat(source.getTrustedRevision(revision, new LogTaskListener(Logger.getAnonymousLogger(), Level.INFO)), sameInstance(revision)); } private PullRequestSCMRevision createRevision(String sourceOwner) { diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java index 1ee1ac115..9b3f9fe5b 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java @@ -38,7 +38,7 @@ public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCor assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.originPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) )); } @@ -62,7 +62,7 @@ public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorr assertThat(ctx.prefilters(), is(Collections.emptyList())); assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.originPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) )); } @@ -87,7 +87,7 @@ public void given__disoverMergeOnly__when__appliedToContext__then__strategiesCor assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.originPRStrategies(), Matchers.is(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) )); } @@ -111,7 +111,7 @@ public void given__programmaticConstructor__when__appliedToContext__then__strate assertThat(ctx.filters(), is(Collections.emptyList())); assertThat(ctx.originPRStrategies(), Matchers.is(EnumSet.allOf(ChangeRequestCheckoutStrategy.class))); - assertThat(ctx.authorities(), (Matcher) hasItem( + assertThat(ctx.authorities(), hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) )); } From 11cfd561547fd2a3174a9e6a453a1ec9a7c6e863 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Tue, 4 Feb 2020 08:54:57 +0100 Subject: [PATCH 13/49] Corrected links to github --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b6eeeeca..c27c8ff9a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # GitHub Branch Source Plugin [![Jenkins Plugin](https://img.shields.io/jenkins/plugin/v/github-branch-source)](https://plugins.jenkins.io/github-branch-source) -[![Changelog](https://img.shields.io/github/v/tag/jenkinsci/github-branch-source-plugin?label=changelog)](https://github.com/jenkinsci/github-branch-source/blob/master/CHANGELOG.md) +[![Changelog](https://img.shields.io/github/v/tag/jenkinsci/github-branch-source-plugin?label=changelog)](https://github.com/jenkinsci/github-branch-source-plugin/blob/master/CHANGELOG.md) [![Jenkins Plugin Installs](https://img.shields.io/jenkins/plugin/i/github-branch-source?color=blue)](https://plugins.jenkins.io/github-branch-source) -[![Contributors](https://img.shields.io/github/contributors/jenkinsci/github-branch-source-plugin.svg)](https://github.com/jenkinsci/github-branch-source/contributors) +[![Contributors](https://img.shields.io/github/contributors/jenkinsci/github-branch-source-plugin.svg)](https://github.com/jenkinsci/github-branch-source-plugin/contributors) ## Introduction The GitHub Branch Source plugin allows you to create a new project based on the repository structure from one or more From 3a034c3cf450f7d94bdff212e1c841cb1b2cf0c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 22:54:31 +0100 Subject: [PATCH 14/49] Simplify creating an empty iterator --- .../jenkinsci/plugins/github_branch_source/GitHubSCMSource.java | 2 +- .../plugins/github_branch_source/GithubSCMSourceTagsTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java index 711eb39c2..f77436e09 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java @@ -2539,7 +2539,7 @@ public Iterator iterator() { iterator = iterable.iterator(); } catch (Error e) { if (e.getCause() instanceof GHFileNotFoundException) { - return Collections.emptyList().iterator(); + return Collections.emptyIterator(); } throw e; } diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceTagsTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceTagsTest.java index 3217072e6..7539103d9 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceTagsTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceTagsTest.java @@ -170,7 +170,7 @@ public void testExistingMultipleTagsGHFileNotFoundExceptionIteratable() throws I //Expected: When initially getting multiple tags, there will then be a thrown filenotfound which returns an empty list //Then for the second tag iterator created it returns an IO error Iterator tags = new GitHubSCMSource.LazyTags(request, repoSpy).iterator(); - assertEquals(Collections.emptyList().iterator(), tags); + assertEquals(Collections.emptyIterator(), tags); try{ Iterator tags2 = new GitHubSCMSource.LazyTags(request, repoSpy).iterator(); fail("This should throw an exception"); From 6127e921b223a9fd1d885bacb636886d5d551beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 22:20:51 +0100 Subject: [PATCH 15/49] Simplify adding list elements to a list --- .../plugins/github_branch_source/GitHubSCMNavigator.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index e4b2e1ea3..460ed386e 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -1475,9 +1475,7 @@ public boolean test(SCMTraitDescriptor scmTraitDescriptor) { @SuppressWarnings("unused") // jelly public List>> getTraitsDefaults() { - List>> result = new ArrayList<>(); - result.addAll(delegate.getTraitsDefaults()); - return result; + return new ArrayList<>(delegate.getTraitsDefaults()); } static { From a39b9d0211a52311a77bee7f2f405b02d64d7ae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 22:49:19 +0100 Subject: [PATCH 16/49] Simplify not required Stream usage --- .../plugins/github_branch_source/ApiRateLimitCheckerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java index 545df4914..357366227 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java @@ -328,7 +328,7 @@ public void ThrottleForNormalizeTestWithinIdeal() throws Exception { assertEquals(1, countOfOutputLinesContaining("under budget")); // The last scenario will trigger back to under budget with a full limit but no new messages - assertEquals(8, handler.getView().stream().count()); + assertEquals(8, handler.getView().size()); } /** From 42a2234b2a501f299f10206bad81c2ff9a87cd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Tue, 4 Feb 2020 00:11:23 +0100 Subject: [PATCH 17/49] Simplify object comparison --- .../plugins/github_branch_source/Connector.java | 3 ++- .../jenkinsci/plugins/github_branch_source/Endpoint.java | 3 ++- .../github_branch_source/GitHubNotificationContext.java | 9 +++++---- .../github_branch_source/GitHubNotificationRequest.java | 7 ++++--- .../github_branch_source/GitHubOrgMetadataAction.java | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 99b681fa2..26cf372ba 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -63,6 +63,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Random; import java.util.WeakHashMap; import java.util.concurrent.TimeUnit; @@ -612,7 +613,7 @@ public boolean equals(Object o) { Details details = (Details) o; - if (apiUrl == null ? details.apiUrl != null : !apiUrl.equals(details.apiUrl)) { + if (!Objects.equals(apiUrl, details.apiUrl)) { return false; } return StringUtils.equals(credentialsHash, details.credentialsHash); diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java index f5ba146d6..477c1809d 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java @@ -38,6 +38,7 @@ import java.io.ObjectStreamException; import java.net.MalformedURLException; import java.net.URL; +import java.util.Objects; import java.util.logging.Logger; import java.util.logging.Level; @@ -116,7 +117,7 @@ public boolean equals(Object o) { Endpoint endpoint = (Endpoint) o; - if (apiUri != null ? !apiUri.equals(endpoint.apiUri) : endpoint.apiUri != null) { + if (!Objects.equals(apiUri, endpoint.apiUri)) { return false; } diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationContext.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationContext.java index 0a2186b44..03d6e4b6c 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationContext.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationContext.java @@ -29,6 +29,7 @@ import hudson.model.Result; import hudson.model.Run; import hudson.model.TaskListener; +import java.util.Objects; import jenkins.scm.api.SCMHead; import jenkins.scm.api.SCMSource; import org.jenkinsci.plugins.displayurlapi.DisplayURLProvider; @@ -120,10 +121,10 @@ public boolean equals(Object o) { GitHubNotificationContext that = (GitHubNotificationContext) o; - if (job != null ? !job.equals(that.job) : that.job != null) return false; - if (build != null ? !build.equals(that.build) : that.build != null) return false; - if (source != null ? !source.equals(that.source) : that.source != null) return false; - return head != null ? head.equals(that.head) : that.head == null; + if (!Objects.equals(job, that.job)) return false; + if (!Objects.equals(build, that.build)) return false; + if (!Objects.equals(source, that.source)) return false; + return Objects.equals(head, that.head); } /** diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationRequest.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationRequest.java index c728a5238..cf17dc9ef 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationRequest.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubNotificationRequest.java @@ -24,6 +24,7 @@ package org.jenkinsci.plugins.github_branch_source; +import java.util.Objects; import org.kohsuke.github.GHCommitState; /** @@ -128,9 +129,9 @@ public boolean equals(Object o) { GitHubNotificationRequest that = (GitHubNotificationRequest) o; if (ignoreError != that.ignoreError) return false; - if (context != null ? !context.equals(that.context) : that.context != null) return false; - if (url != null ? !url.equals(that.url) : that.url != null) return false; - if (message != null ? !message.equals(that.message) : that.message != null) return false; + if (!Objects.equals(context, that.context)) return false; + if (!Objects.equals(url, that.url)) return false; + if (!Objects.equals(message, that.message)) return false; return state == that.state; } diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubOrgMetadataAction.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubOrgMetadataAction.java index 6c20c939d..9db32fa54 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubOrgMetadataAction.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubOrgMetadataAction.java @@ -30,6 +30,7 @@ import hudson.model.Hudson; import java.io.IOException; import java.io.ObjectStreamException; +import java.util.Objects; import jenkins.scm.api.metadata.AvatarMetadataAction; import org.apache.commons.lang.StringUtils; import org.kohsuke.github.GHUser; @@ -117,8 +118,7 @@ public boolean equals(Object o) { GitHubOrgMetadataAction that = (GitHubOrgMetadataAction) o; - return avatar != null ? avatar.equals(that.avatar) : that.avatar == null; - + return Objects.equals(avatar, that.avatar); } /** From 1fd1bef94024995e4edc28145e8d46d1206191fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 23:57:52 +0100 Subject: [PATCH 18/49] Use try-with-resources for automatic resource cleanup --- .../github_branch_source/GitHubSCMNavigator.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 460ed386e..9c7056d74 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -927,9 +927,8 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru } GitHubSCMNavigatorContext gitHubSCMNavigatorContext = new GitHubSCMNavigatorContext().withTraits(traits); - GitHubSCMNavigatorRequest request = gitHubSCMNavigatorContext.newRequest(this, observer); - try { + try (GitHubSCMNavigatorRequest request = gitHubSCMNavigatorContext.newRequest(this, observer)) { SourceFactory sourceFactory = new SourceFactory(request); WitnessImpl witness = new WitnessImpl(listener); @@ -1039,8 +1038,6 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru throw new AbortException( repoOwner + " does not correspond to a known GitHub User Account or Organization"); - } finally { - request.close(); } } finally { Connector.release(github); @@ -1094,9 +1091,8 @@ public void visitSource(String sourceName, SCMSourceObserver observer) } GitHubSCMNavigatorContext gitHubSCMNavigatorContext = new GitHubSCMNavigatorContext().withTraits(traits); - GitHubSCMNavigatorRequest request = gitHubSCMNavigatorContext.newRequest(this, observer); - try { + try (GitHubSCMNavigatorRequest request = gitHubSCMNavigatorContext.newRequest(this, observer)) { SourceFactory sourceFactory = new SourceFactory(request); WitnessImpl witness = new WitnessImpl(listener); @@ -1199,8 +1195,6 @@ public void visitSource(String sourceName, SCMSourceObserver observer) throw new AbortException( repoOwner + " does not correspond to a known GitHub User Account or Organization"); - } finally { - request.close(); } } finally { Connector.release(github); From a22a5f516aff6e60af03ced68092483cf9a47fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Tue, 4 Feb 2020 22:08:49 +0100 Subject: [PATCH 19/49] Use diamond operator to reduce type duplication --- .../plugins/github_branch_source/GitHubConfiguration.java | 4 ++-- .../plugins/github_branch_source/GitHubSCMNavigator.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConfiguration.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConfiguration.java index 74db1d6a9..8982040a7 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConfiguration.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConfiguration.java @@ -122,9 +122,9 @@ public static String normalizeApiUri(@CheckForNull String apiUri) { } public synchronized void setEndpoints(@CheckForNull List endpoints) { - endpoints = new ArrayList(endpoints == null ? Collections.emptyList() : endpoints); + endpoints = new ArrayList<>(endpoints == null ? Collections.emptyList() : endpoints); // remove duplicates and empty urls - Set apiUris = new HashSet(); + Set apiUris = new HashSet<>(); for (Iterator iterator = endpoints.iterator(); iterator.hasNext(); ) { Endpoint endpoint = iterator.next(); if (StringUtils.isBlank(endpoint.getApiUri()) || apiUris.contains(endpoint.getApiUri())) { diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 9c7056d74..250ab945c 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -339,7 +339,7 @@ public void setTraits(@CheckForNull SCMTrait[] traits) { */ @Override public void setTraits(@CheckForNull List>> traits) { - this.traits = traits != null ? new ArrayList<>(traits) : new ArrayList>>(); + this.traits = traits != null ? new ArrayList<>(traits) : new ArrayList<>(); } From 9221d676de90103066ce37bec7c08c2b6b10b96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 22:51:30 +0100 Subject: [PATCH 20/49] Remove not required null check --- .../plugins/github_branch_source/GitHubSCMFileSystem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystem.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystem.java index b3be199db..753b27434 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystem.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystem.java @@ -275,7 +275,7 @@ public SCMFileSystem build(@NonNull SCMSource source, @NonNull SCMHead head, @Ch refName = "tags/" + head.getName(); } else if (head instanceof PullRequestSCMHead) { refName = null; - if (rev != null && rev instanceof PullRequestSCMRevision) { + if (rev instanceof PullRequestSCMRevision) { PullRequestSCMRevision prRev = (PullRequestSCMRevision) rev; if (((PullRequestSCMHead)head).isMerge()) { if (prRev.getMergeHash() == null) { From e4299b1b53f868c1970c6957c688b18c5f725423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 22:56:37 +0100 Subject: [PATCH 21/49] Remove not required character escaping --- .../plugins/github_branch_source/FillErrorResponse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/FillErrorResponse.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/FillErrorResponse.java index 347a16b60..b0a8c059a 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/FillErrorResponse.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/FillErrorResponse.java @@ -26,8 +26,8 @@ public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object nod rsp.setContentType("text/html;charset=UTF-8"); rsp.setHeader("X-Jenkins-Select-Error", clearList ? "clear" : "retain"); rsp.getWriter().print( - "
" + Util.escape(getMessage()) + + "
" + Util.escape(getMessage()) + "
"); } From 2a83742bf5ba0598899a00c8670c424b2e3df2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Tue, 4 Feb 2020 21:55:06 +0100 Subject: [PATCH 22/49] Remove not required unchecked casts --- .../github_branch_source/BranchDiscoveryTraitTest.java | 7 +++---- .../ForkPullRequestDiscoveryTraitTest.java | 8 ++++---- .../OriginPullRequestDiscoveryTraitTest.java | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java index 0343fbe18..e49b3591b 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java @@ -29,7 +29,7 @@ public void given__disoverAll__when__appliedToContext__then__noFilter() throws E assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class) ))); BranchDiscoveryTrait instance = new BranchDiscoveryTrait(true, true); @@ -50,7 +50,7 @@ public void given__excludingPRs__when__appliedToContext__then__filter() throws E assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class) ))); BranchDiscoveryTrait instance = new BranchDiscoveryTrait(true, false); @@ -72,7 +72,7 @@ public void given__onlyPRs__when__appliedToContext__then__filter() throws Except assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(BranchDiscoveryTrait.BranchSCMHeadAuthority.class) ))); BranchDiscoveryTrait instance = new BranchDiscoveryTrait(false, true); @@ -95,5 +95,4 @@ public void given__descriptor__when__displayingOptions__then__allThreePresent() assertThat(options.get(1).value, is("2")); assertThat(options.get(2).value, is("3")); } - } diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java index 8579947eb..9cb3fbb00 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java @@ -32,7 +32,7 @@ public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCor assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) ))); ForkPullRequestDiscoveryTrait instance = new ForkPullRequestDiscoveryTrait( @@ -57,7 +57,7 @@ public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorr assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) ))); ForkPullRequestDiscoveryTrait instance = new ForkPullRequestDiscoveryTrait( @@ -82,7 +82,7 @@ public void given__disoverMergeOnly__when__appliedToContext__then__strategiesCor assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) ))); ForkPullRequestDiscoveryTrait instance = new ForkPullRequestDiscoveryTrait( @@ -107,7 +107,7 @@ public void given__nonDefaultTrust__when__appliedToContext__then__authoritiesCor assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(ForkPullRequestDiscoveryTrait.TrustContributors.class) ))); ForkPullRequestDiscoveryTrait instance = new ForkPullRequestDiscoveryTrait( diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java index 9b3f9fe5b..ae0423e68 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java @@ -26,7 +26,7 @@ public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCor assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) ))); OriginPullRequestDiscoveryTrait instance = new OriginPullRequestDiscoveryTrait( @@ -50,7 +50,7 @@ public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorr assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) ))); OriginPullRequestDiscoveryTrait instance = new OriginPullRequestDiscoveryTrait( @@ -74,7 +74,7 @@ public void given__disoverMergeOnly__when__appliedToContext__then__strategiesCor assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) ))); OriginPullRequestDiscoveryTrait instance = new OriginPullRequestDiscoveryTrait( @@ -99,7 +99,7 @@ public void given__programmaticConstructor__when__appliedToContext__then__strate assumeThat(ctx.wantPRs(), is(false)); assumeThat(ctx.prefilters(), is(Collections.emptyList())); assumeThat(ctx.filters(), is(Collections.emptyList())); - assumeThat(ctx.authorities(), not((Matcher) hasItem( + assumeThat(ctx.authorities(), not(hasItem( instanceOf(OriginPullRequestDiscoveryTrait.OriginChangeRequestSCMHeadAuthority.class) ))); OriginPullRequestDiscoveryTrait instance = From a3e87a101982c72b67d5edb2a24e6a8354ed6b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 23:48:25 +0100 Subject: [PATCH 23/49] Remove unused assignments These variables are overwritten in every case. --- .../jenkinsci/plugins/github_branch_source/GitHubSCMSource.java | 2 +- .../ForkPullRequestDiscoveryTrait2Test.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java index f77436e09..eeca78756 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java @@ -1824,7 +1824,7 @@ protected List retrieveActions(@NonNull SCMHead head, GitHubLink repoLink = ((Actionable) owner).getAction(GitHubLink.class); if (repoLink != null) { String url; - ObjectMetadataAction metadataAction = null; + ObjectMetadataAction metadataAction; if (head instanceof PullRequestSCMHead) { // pull request to this repository int number = ((PullRequestSCMHead) head).getNumber(); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java index b6681bf2c..991a322f1 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait2Test.java @@ -67,7 +67,7 @@ public void configRoundtripWithRawUrl() throws Exception { private void assertRoundTrip(WorkflowMultiBranchProject p, SCMHeadAuthority trust, boolean configuredByUrl) throws Exception { - GitHubSCMSource s = null; + GitHubSCMSource s; if (configuredByUrl) s = new GitHubSCMSource("", "", "https://github.com/nobody/nowhere", true); else From 262be7d43ac0ed78eeb6d7e2627cc8dfefa2cb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 22:14:22 +0100 Subject: [PATCH 24/49] Remove unused imports --- .../jenkinsci/plugins/github_branch_source/Connector.java | 3 --- .../plugins/github_branch_source/GitHubSCMBuilder.java | 1 - .../github_branch_source/GitHubSCMSourceRequest.java | 1 - .../plugins/github_branch_source/SSHCheckoutTrait.java | 1 - .../github_branch_source/BranchDiscoveryTraitTest.java | 1 - .../ForkPullRequestDiscoveryTraitTest.java | 2 -- .../github_branch_source/GitHubSCMBuilderTest.java | 3 --- .../github_branch_source/GitHubSCMFileSystemTest.java | 8 +------- .../github_branch_source/GitHubSCMNavigatorTest.java | 3 --- .../plugins/github_branch_source/GitHubSCMSourceTest.java | 1 - .../plugins/github_branch_source/GitSCMSourceBase.java | 1 - .../github_branch_source/GithubSCMSourceBranchesTest.java | 1 - .../OriginPullRequestDiscoveryTraitTest.java | 2 -- .../github_branch_source/PullRequestSCMRevisionTest.java | 1 - 14 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 26cf372ba..f48386431 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -77,11 +77,8 @@ import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.gitclient.GitClient; import org.jenkinsci.plugins.github.config.GitHubServerConfig; -import org.kohsuke.accmod.Restricted; -import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.github.GitHub; import org.kohsuke.github.GitHubBuilder; -import org.kohsuke.github.HttpConnector; import org.kohsuke.github.RateLimitHandler; import org.kohsuke.github.extras.OkHttpConnector; diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilder.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilder.java index 987f620ff..a6028afc3 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilder.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilder.java @@ -34,7 +34,6 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.model.Item; import hudson.model.Queue; -import hudson.model.queue.Tasks; import hudson.plugins.git.GitSCM; import hudson.plugins.git.browser.GithubWeb; import hudson.security.ACL; diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java index 20a9aec58..09cd7f4dd 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceRequest.java @@ -39,7 +39,6 @@ import jenkins.scm.api.SCMHeadOrigin; import jenkins.scm.api.SCMSource; import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy; -import jenkins.scm.api.mixin.TagSCMHead; import jenkins.scm.api.trait.SCMSourceRequest; import net.jcip.annotations.GuardedBy; import org.kohsuke.github.GHBranch; diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java index aa583aa34..2c9bb7cd7 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java @@ -35,7 +35,6 @@ import hudson.Util; import hudson.model.Item; import hudson.model.Queue; -import hudson.model.queue.Tasks; import hudson.plugins.git.GitSCM; import hudson.scm.SCM; import hudson.security.ACL; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java index e49b3591b..e40271a7c 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java @@ -5,7 +5,6 @@ import jenkins.scm.api.SCMHeadObserver; import jenkins.scm.api.trait.SCMHeadFilter; import jenkins.scm.api.trait.SCMHeadPrefilter; -import org.hamcrest.Matcher; import org.junit.ClassRule; import org.junit.Test; import org.jvnet.hudson.test.JenkinsRule; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java index 9cb3fbb00..0feb20290 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java @@ -3,12 +3,10 @@ import hudson.util.XStream2; import java.util.Collections; import java.util.EnumSet; -import java.util.Set; import jenkins.scm.api.SCMHeadObserver; import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy; import jenkins.scm.api.trait.SCMHeadFilter; import jenkins.scm.api.trait.SCMHeadPrefilter; -import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.junit.Test; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java index 207552a90..05a9537ba 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMBuilderTest.java @@ -17,15 +17,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import jenkins.plugins.git.AbstractGitSCMSource; import jenkins.plugins.git.GitSCMSourceDefaults; import jenkins.plugins.git.MergeWithGitSCMExtension; -import jenkins.scm.api.SCMHead; import jenkins.scm.api.SCMHeadOrigin; -import jenkins.scm.api.SCMRevision; import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy; import org.eclipse.jgit.transport.RemoteConfig; import org.jenkinsci.plugins.gitclient.GitClient; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java index ff40011a6..97c5b4f1b 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java @@ -33,10 +33,8 @@ import com.github.tomakehurst.wiremock.http.Request; import com.github.tomakehurst.wiremock.http.Response; import com.github.tomakehurst.wiremock.junit.WireMockRule; +import hudson.AbortException; import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; import jenkins.plugins.git.AbstractGitSCMSource; import jenkins.scm.api.SCMFile; import jenkins.scm.api.SCMFileSystem; @@ -44,8 +42,6 @@ import jenkins.scm.api.SCMHeadOrigin; import jenkins.scm.api.SCMRevision; import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy; - -import org.apache.commons.io.IOUtils; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.ClassRule; @@ -55,8 +51,6 @@ import org.junit.runners.Parameterized; import org.jvnet.hudson.test.JenkinsRule; -import hudson.AbortException; - import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java index 645b7a08f..594f71601 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigatorTest.java @@ -41,7 +41,6 @@ import com.github.tomakehurst.wiremock.junit.WireMockRule; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; -import hudson.model.Action; import hudson.model.Item; import hudson.model.TaskListener; import hudson.model.User; @@ -82,8 +81,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.get; import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static org.hamcrest.Matchers.*; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java index fb446a148..b3136aed6 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSourceTest.java @@ -33,7 +33,6 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.AbortException; import hudson.ExtensionList; -import hudson.model.Action; import hudson.model.FreeStyleProject; import hudson.model.Item; import hudson.model.TaskListener; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitSCMSourceBase.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitSCMSourceBase.java index 2406b5ee3..ef0faea2a 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitSCMSourceBase.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitSCMSourceBase.java @@ -19,7 +19,6 @@ import java.util.EnumSet; import static com.github.tomakehurst.wiremock.client.WireMock.*; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; public class GitSCMSourceBase{ diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceBranchesTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceBranchesTest.java index 3562e02ff..4915878fe 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceBranchesTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceBranchesTest.java @@ -1,6 +1,5 @@ package org.jenkinsci.plugins.github_branch_source; -import com.github.tomakehurst.wiremock.stubbing.Scenario; import java.io.IOException; import java.util.Collections; import java.util.Iterator; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java index ae0423e68..9618736b5 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java @@ -2,12 +2,10 @@ import java.util.Collections; import java.util.EnumSet; -import java.util.Set; import jenkins.scm.api.SCMHeadObserver; import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy; import jenkins.scm.api.trait.SCMHeadFilter; import jenkins.scm.api.trait.SCMHeadPrefilter; -import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.junit.Test; diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevisionTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevisionTest.java index 5d8b27e0f..274136652 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevisionTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevisionTest.java @@ -38,7 +38,6 @@ import jenkins.scm.api.SCMHeadOrigin; import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy; -import org.apache.tools.ant.taskdefs.condition.IsTrue; import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; From 47fd3fa1802da7bf028183f52238fd1cc050b8e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Tue, 4 Feb 2020 22:15:51 +0100 Subject: [PATCH 25/49] Add missing @NonNull annotation --- .../plugins/github_branch_source/GitHubSCMNavigator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 250ab945c..df517febb 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -1468,6 +1468,7 @@ public boolean test(SCMTraitDescriptor scmTraitDescriptor) { } @SuppressWarnings("unused") // jelly + @NonNull public List>> getTraitsDefaults() { return new ArrayList<>(delegate.getTraitsDefaults()); } From a277a71a9f75eed0a37f04cd1f35172f5696d13e Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Tue, 5 Nov 2019 16:53:44 +0000 Subject: [PATCH 26/49] Add support for GitHub app authentication --- pom.xml | 20 +++ .../github_branch_source/Connector.java | 69 +++++++++- .../GitHubSCMNavigator.java | 4 +- .../InvalidPrivateKeyException.java | 8 ++ .../github_branch_source/JwtHelper.java | 82 +++++++++++ .../help-credentialsId.html | 15 +- .../GitHubSCMSource/help-credentialsId.html | 11 ++ .../github_branch_source/JwtHelperTest.java | 128 ++++++++++++++++++ 8 files changed, 324 insertions(+), 13 deletions(-) create mode 100644 src/main/java/org/jenkinsci/plugins/github_branch_source/InvalidPrivateKeyException.java create mode 100644 src/main/java/org/jenkinsci/plugins/github_branch_source/JwtHelper.java create mode 100644 src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java diff --git a/pom.xml b/pom.xml index dbbab0a0f..ceb9db148 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,7 @@ 2.2 true 1.35 + 0.10.5 @@ -79,6 +80,25 @@ display-url-api 2.0 + + + io.jsonwebtoken + jjwt-api + ${jjwt.version} + + + io.jsonwebtoken + jjwt-impl + ${jjwt.version} + runtime + + + io.jsonwebtoken + jjwt-jackson + ${jjwt.version} + runtime + + org.jenkins-ci.plugins diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 99b681fa2..9b0be9f1f 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -25,6 +25,7 @@ package org.jenkinsci.plugins.github_branch_source; import com.cloudbees.jenkins.GitHubWebHook; +import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey; import com.cloudbees.plugins.credentials.CredentialsMatcher; import com.cloudbees.plugins.credentials.CredentialsMatchers; import com.cloudbees.plugins.credentials.CredentialsNameProvider; @@ -78,13 +79,19 @@ import org.jenkinsci.plugins.github.config.GitHubServerConfig; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; +import org.kohsuke.github.GHApp; +import org.kohsuke.github.GHAppInstallation; +import org.kohsuke.github.GHAppInstallationToken; import org.kohsuke.github.GitHub; import org.kohsuke.github.GitHubBuilder; import org.kohsuke.github.HttpConnector; import org.kohsuke.github.RateLimitHandler; import org.kohsuke.github.extras.OkHttpConnector; +import static com.cloudbees.plugins.credentials.CredentialsMatchers.anyOf; +import static com.cloudbees.plugins.credentials.CredentialsMatchers.instanceOf; import static java.util.logging.Level.FINE; +import static org.jenkinsci.plugins.github_branch_source.JwtHelper.createJWT; /** * Utilities that could perhaps be moved into {@code github-api}. @@ -106,6 +113,7 @@ protected boolean removeEldestEntry(Map.Entry eldest) { }; private static final Random ENTROPY = new Random(); private static final String SALT = Long.toHexString(ENTROPY.nextLong()); + private static final String ERROR_AUTHENTICATING_GITHUB_APP = "Couldn't find GitHub app installation %s"; private Connector() { throw new IllegalAccessError("Utility class"); @@ -198,13 +206,21 @@ public static FormValidation checkScanCredentials(@CheckForNull Item context, St GitHub connector = Connector.connect(apiUri, credentials); try { try { - return FormValidation.ok("User %s", connector.getMyself().getLogin()); - } catch (IOException e){ - return FormValidation.error("Invalid credentials"); + boolean githubAppAuthentication = credentials instanceof SSHUserPrivateKey; + if (githubAppAuthentication) { + int remaining = connector.getRateLimit().getRemaining(); + return FormValidation.ok("GHApp verified, remaining rate limit: %d", remaining); + } + + return FormValidation.ok("User %s", connector.isCredentialValid()); + } catch (Exception e) { + return FormValidation.error("Invalid credentials: %s", e.getMessage()); } } finally { Connector.release(connector); } + } catch (IllegalArgumentException | InvalidPrivateKeyException e) { + return FormValidation.error(e.getMessage()); } catch (IOException e) { // ignore, never thrown LOGGER.log(Level.WARNING, "Exception validating credentials {0} on {1}", new Object[]{ @@ -309,6 +325,9 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta } else if (credentials instanceof StandardUsernamePasswordCredentials) { StandardUsernamePasswordCredentials c = (StandardUsernamePasswordCredentials) credentials; hash = Util.getDigestOf(c.getPassword().getPlainText() + SALT); + } else if (credentials instanceof SSHUserPrivateKey) { + SSHUserPrivateKey c = (SSHUserPrivateKey) credentials; + hash = Util.getDigestOf(c.getPrivateKeys().get(0) + SALT); } else { // TODO OAuth support throw new IOException("Unsupported credential type: " + credentials.getClass().getName()); @@ -331,6 +350,7 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta String password; String hash; String authHash; + boolean githubApp = false; Jenkins jenkins = Jenkins.get(); if (credentials == null) { username = null; @@ -343,6 +363,14 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta password = c.getPassword().getPlainText(); hash = Util.getDigestOf(password + SALT); // want to ensure pooling by credential authHash = Util.getDigestOf(password + "::" + jenkins.getLegacyInstanceId()); + } else if (credentials instanceof SSHUserPrivateKey) { + SSHUserPrivateKey c = (SSHUserPrivateKey) credentials; + username = c.getUsername(); + password = c.getPrivateKeys().get(0); + hash = Util.getDigestOf(password + SALT); + authHash = Util.getDigestOf(password + "::" + jenkins.getLegacyInstanceId()); + + githubApp = true; } else { // TODO OAuth support throw new IOException("Unsupported credential type: " + credentials.getClass().getName()); @@ -394,8 +422,10 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta gb.withConnector(new OkHttpConnector(new OkUrlFactory(client))); - if (username != null) { + if (username != null && !githubApp) { gb.withPassword(username, password); + } else if (username != null) { + gb.withOAuthToken(generateAppInstallationToken(username, password), ""); } hub = gb.build(); @@ -406,6 +436,29 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta } } + @SuppressWarnings("deprecation") // preview features are required for GitHub app integration, GitHub api adds deprecated to all preview methods + private static String generateAppInstallationToken(String appId, String appPrivateKey) { + try { + String jwtToken = createJWT(appId, appPrivateKey); + GitHub gitHubApp = new GitHubBuilder().withJwtToken(jwtToken).build(); + + GHApp app = gitHubApp.getApp(); + + List appInstallations = app.listInstallations().asList(); + if (!appInstallations.isEmpty()) { + GHAppInstallation appInstallation = appInstallations.get(0); + GHAppInstallationToken appInstallationToken = appInstallation + .createToken(appInstallation.getPermissions()) + .create(); + + return appInstallationToken.getToken(); + } + } catch (IOException e) { + throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId), e); + } + throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId)); + } + public static void release(@CheckForNull GitHub hub) { if (hub == null) { return; @@ -453,8 +506,10 @@ private static void unused(@Nonnull GitHub hub) { } private static CredentialsMatcher githubScanCredentialsMatcher() { - // TODO OAuth credentials - return CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class)); + return anyOf( + instanceOf(StandardUsernamePasswordCredentials.class), + instanceOf(SSHUserPrivateKey.class) + ); } static List githubDomainRequirements(String apiUri) { @@ -512,7 +567,7 @@ static boolean isCredentialValid(GitHub gitHub) { return true; } else { try { - gitHub.getMyself(); + gitHub.getRateLimit(); return true; } catch (IOException e) { if (LOGGER.isLoggable(FINE)) { diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index e4b2e1ea3..122424d13 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -25,6 +25,7 @@ package org.jenkinsci.plugins.github_branch_source; import com.cloudbees.jenkins.GitHubWebHook; +import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey; import com.cloudbees.plugins.credentials.CredentialsNameProvider; import com.cloudbees.plugins.credentials.common.StandardCredentials; import com.cloudbees.plugins.credentials.common.StandardListBoxModel; @@ -933,7 +934,8 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru SourceFactory sourceFactory = new SourceFactory(request); WitnessImpl witness = new WitnessImpl(listener); - if (!github.isAnonymous()) { + boolean githubAppAuthentication = credentials instanceof SSHUserPrivateKey; + if (!github.isAnonymous() && !githubAppAuthentication) { GHMyself myself; try { // Requires an authenticated access diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/InvalidPrivateKeyException.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/InvalidPrivateKeyException.java new file mode 100644 index 000000000..cc1f8d65f --- /dev/null +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/InvalidPrivateKeyException.java @@ -0,0 +1,8 @@ +package org.jenkinsci.plugins.github_branch_source; + +public class InvalidPrivateKeyException extends RuntimeException { + + public InvalidPrivateKeyException(String message) { + super(message); + } +} diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/JwtHelper.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/JwtHelper.java new file mode 100644 index 000000000..6201d415a --- /dev/null +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/JwtHelper.java @@ -0,0 +1,82 @@ +package org.jenkinsci.plugins.github_branch_source; + +import io.jsonwebtoken.JwtBuilder; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import java.security.GeneralSecurityException; +import java.security.Key; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.spec.PKCS8EncodedKeySpec; +import java.util.Base64; +import java.util.Date; +import java.util.Objects; + +import static java.util.Objects.requireNonNull; + +class JwtHelper { + + /** + * Create a JWT for authenticating to GitHub as an app installation + * @param githubAppId the app ID + * @param privateKey PKC#8 formatted private key + * @return JWT for authenticating to GitHub + */ + static String createJWT(String githubAppId, final String privateKey) { + requireNonNull(githubAppId, privateKey); + + SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.RS256; + + long nowMillis = System.currentTimeMillis(); + Date now = new Date(nowMillis); + + Key signingKey; + try { + signingKey = getPrivateKeyFromString(privateKey); + } catch (GeneralSecurityException e) { + throw new IllegalArgumentException("Couldn't parse private key for GitHub app, make sure it's PKCS#8 format", e); + } + + JwtBuilder builder = Jwts.builder() + .setIssuedAt(now) + .setIssuer(githubAppId) + .signWith(signingKey, signatureAlgorithm); + + long expMillis = nowMillis + (60 * 1000 * 10); + Date exp = new Date(expMillis); + builder.setExpiration(exp); + + return builder.compact(); + } + + /** + * Convert a PKCS#8 formatted private key in string format into a java PrivateKey + * @param key PCKS#8 string + * @return private key + * @throws GeneralSecurityException if we couldn't parse the string + */ + private static PrivateKey getPrivateKeyFromString(final String key) throws GeneralSecurityException { + if (key.contains("RSA")) { + throw new InvalidPrivateKeyException( + "Private key must be a PKCS#8 formatted string, to convert it from PKCS#1 use: " + + "openssl pkcs8 -topk8 -inform PEM -outform PEM -in current-key.pem -out new-key.pem -nocrypt" + ); + } + + String privateKeyContent = key.replaceAll("\\n", "") + .replace("-----BEGIN PRIVATE KEY-----", "") + .replace("-----END PRIVATE KEY-----", ""); + + KeyFactory kf = KeyFactory.getInstance("RSA"); + + try { + byte[] decode = Base64.getDecoder().decode(privateKeyContent); + PKCS8EncodedKeySpec keySpecPKCS8 = new PKCS8EncodedKeySpec(decode); + + return kf.generatePrivate(keySpecPKCS8); + } catch (IllegalArgumentException e) { + throw new InvalidPrivateKeyException("Failed to decode private key: " + e.getMessage()); + } + } + +} diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html index a77b93fbd..322f0a622 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html @@ -3,11 +3,16 @@ Credentials used to scan branches and pull requests, check out sources and mark commit statuses.

-

- Note that only "username with password" credentials are supported. - Existing credentials of other kinds will be filtered out. This is because Jenkins - uses the GitHub API, which does not support other ways of authentication. -

+ The following credential types are supported: +
    +
  • + "Username with password" +
  • +
  • + "SSH Username with private key" - this is for authenticating as a GitHub app. + The username should be the 'GitHub app ID'. +
  • +

If none is given, only the public repositories will be scanned, and commit status will not be set on GitHub. diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html index a77b93fbd..df36ebcba 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html @@ -3,6 +3,17 @@ Credentials used to scan branches and pull requests, check out sources and mark commit statuses.

+ The following credential types are supported: +
    +
  • + "Username with password" +
  • +
  • + "SSH Username with private key" - this is for authenticating as a GitHub app. + The username should be the 'GitHub app ID'. +
  • +
+

Note that only "username with password" credentials are supported. Existing credentials of other kinds will be filtered out. This is because Jenkins diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java new file mode 100644 index 000000000..139ec5327 --- /dev/null +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java @@ -0,0 +1,128 @@ +package org.jenkinsci.plugins.github_branch_source; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jws; +import io.jsonwebtoken.Jwts; +import java.security.GeneralSecurityException; +import java.security.KeyFactory; +import java.security.PublicKey; +import java.security.spec.X509EncodedKeySpec; +import java.util.Base64; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; +import static org.jenkinsci.plugins.github_branch_source.JwtHelper.createJWT; +import static org.mockito.ArgumentMatchers.contains; + +public class JwtHelperTest { + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + // https://stackoverflow.com/a/22176759/4951015 + private static final String PKCS8_PRIVATE_KEY = "-----BEGIN PRIVATE KEY-----\n" + + "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD7vHsVwyDV8cj7\n" + + "5yR4WWl6rlgf/e5zmeBgtm0PCgnitcSbD5FU33301DPY5a7AtqVBOwEnE14L9XS7\n" + + "ov61U+x1m4aQmqR/dPQaA2ayh2cYPszWNQMp42ArDIfg7DhSrvsRJKHsbPXlPjqe\n" + + "c0udLqhSLVIO9frNLf+dAsLsgYk8O39PKGb33akGG7tWTe0J+akNQjgbS7vOi8sS\n" + + "NLwHIdYfz/Am+6Xmm+J4yVs6+Xt3kOeLdFBkz8H/HGsJq854MbIAK/HuId1MOPS0\n" + + "cDWh37tzRsM+q/HZzYRkc5bhNKw/Mj9jN9jD5GH0Lfea0QFedjppf1KvWdcXn+/W\n" + + "M7OmyfhvAgMBAAECggEAN96H7reExRbJRWbySCeH6mthMZB46H0hODWklK7krMUs\n" + + "okFdPtnvKXQjIaMwGqMuoACJa/O3bq4GP1KYdwPuOdfPkK5RjdwWBOP2We8FKXNe\n" + + "oLfZQOWuxT8dtQSYJ3mgTRi1OzSfikY6Wko6YOMnBj36tUlQZVMtJNqlCjphi9Uz\n" + + "6EyvRURlDG8sBBbC7ods5B0789qk3iGH/97ia+1QIqXAUaVFg3/BA6wkxkbNG2sN\n" + + "tqULgVYTw32Oj/Y/H1Y250RoocTyfsUS3I3aPIlnvcgp2bugWqDyYJ58nDIt3Pku\n" + + "fjImWrNz/pNiEs+efnb0QEk7m5hYwxmyXN4KRSv0OQKBgQD+I3Y3iNKSVr6wXjur\n" + + "OPp45fxS2sEf5FyFYOn3u760sdJOH9fGlmf9sDozJ8Y8KCaQCN5tSe3OM+XDrmiw\n" + + "Cu/oaqJ1+G4RG+6w1RJF+5Nfg6PkUs7eJehUgZ2Tox8Tg1mfVIV8KbMwNi5tXpug\n" + + "MVmA2k9xjc4uMd2jSnSj9NAqrQKBgQD9lIO1tY6YKF0Eb0Qi/iLN4UqBdJfnALBR\n" + + "MjxYxqqI8G4wZEoZEJJvT1Lm6Q3o577N95SihZoj69tb10vvbEz1pb3df7c1HEku\n" + + "LXcyVMvjR/CZ7dOSNgLGAkFfOoPhcF/OjSm4DrGPe3GiBxhwXTBjwJ5TIgEDkVIx\n" + + "ZVo5r7gPCwKBgQCOvsZo/Q4hql2jXNqxGuj9PVkUBNFTI4agWEYyox7ECdlxjks5\n" + + "vUOd5/1YvG+JXJgEcSbWRh8volDdL7qXnx0P881a6/aO35ybcKK58kvd62gEGEsf\n" + + "1jUAOmmTAp2y7SVK7EOp8RY370b2oZxSR0XZrUXQJ3F22wV98ZVAfoLqZQKBgDIr\n" + + "PdunbezAn5aPBOX/bZdZ6UmvbZYwVrHZxIKz2214U/STAu3uj2oiQX6ZwTzBDMjn\n" + + "IKr+z74nnaCP+eAGhztabTPzXqXNUNUn/Zshl60BwKJToTYeJXJTY+eZRhpGB05w\n" + + "Mz7M+Wgvvg2WZcllRnuV0j0UTysLhz1qle0vzLR9AoGBAOukkFFm2RLm9N1P3gI8\n" + + "mUadeAlYRZ5o0MvumOHaB5pDOCKhrqAhop2gnM0f5uSlapCtlhj0Js7ZyS3Giezg\n" + + "38oqAhAYxy2LMoLD7UtsHXNp0OnZ22djcDwh+Wp2YORm7h71yOM0NsYubGbp+CmT\n" + + "Nw9bewRvqjySBlDJ9/aNSeEY\n" + + "-----END PRIVATE KEY-----"; + + private static final String PKCS8_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\n" + + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+7x7FcMg1fHI++ckeFlp\n" + + "eq5YH/3uc5ngYLZtDwoJ4rXEmw+RVN999NQz2OWuwLalQTsBJxNeC/V0u6L+tVPs\n" + + "dZuGkJqkf3T0GgNmsodnGD7M1jUDKeNgKwyH4Ow4Uq77ESSh7Gz15T46nnNLnS6o\n" + + "Ui1SDvX6zS3/nQLC7IGJPDt/Tyhm992pBhu7Vk3tCfmpDUI4G0u7zovLEjS8ByHW\n" + + "H8/wJvul5pvieMlbOvl7d5Dni3RQZM/B/xxrCavOeDGyACvx7iHdTDj0tHA1od+7\n" + + "c0bDPqvx2c2EZHOW4TSsPzI/YzfYw+Rh9C33mtEBXnY6aX9Sr1nXF5/v1jOzpsn4\n" + + "bwIDAQAB\n" + + "-----END PUBLIC KEY-----"; + + + private static final String PKCS1_PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----\n" + + "MIIEpAIBAAKCAQEA26y2ZLYaNKHYg1FehH/WmXZ+SXG9ofLCf7+tR0j/BHbQy1Ck\n" + + "u6Pqxn10nKPrAZSFakNDKI1vf92+Ny8LFitBucs2JaDSm1kUHjZaoCbp2FQmbr28\n" + + "eO+q0oIaJ67WaIF9o1DzCiBBgqCOqZpDdZY1peRPQ7ttBfBvPOi9zEiWplrn2IlL\n" + + "tlndlYtV+KHlIy7odaCaSHjzawTBxLe82lpX5+YHy0doNlI5l/epJMtjcE/l2jEj\n" + + "xMZxWz4ZAiXd8hLYonUzxaup8IMKm4K8eh++4UcXAs0tjA0CGaieeyQZyBLPwFyf\n" + + "k3JStqbBgwaKLzV0D1ayokQNvc0cm4tdgk6gVwIDAQABAoIBAGlZzSdDhhHTxIhF\n" + + "z7RvsrVqdGo4mB9A0zJ89FcJlPPJH51CEZ7Dn+aNaA1vN1dMqScrFtwt6FlEOOMy\n" + + "NnjtSdoWsOMe26IQ+Gr82j2QK/nJcZ0OdYLyPdQy/OQnH0CDSYO3YLdsfL5uzbxc\n" + + "9RlBbn0enzz2d/SvOEnXvJ5p+YXRk3Y8Toccu66nPUKkeWDzZ3Ql/mf2Piw1VwvF\n" + + "/5pvZRiH5Lh5MCc7AxHlDFXRq5jQKxSdJrtHhB/GFRfHg6EOAKfCGbPHwYIMb5BW\n" + + "KNxRRyfpAPhUP9a+GgH4mHXkv+wSR87zE3hbCf7Fg/4mB25Cx4r/34E5W0F0XuCN\n" + + "HzSwXHECgYEA8pdeT6R2mlWDgD7IfhyeYoUcJ0oXvd6dKlGOETlkzkGi4QvP3BsM\n" + + "wg0sELPhuYCOG53SzSW9d5QkqDYJRY4/xg15QV2LYOMpP5b9cjJZRE3Uo9BVIBum\n" + + "EFVZvuGzZaFUO6Zx3xQiQgHuCP8Tx676vTk36ka3fVQV5FdY8tP0HyUCgYEA59ET\n" + + "v6eE2s10T9JeO3htK5TjwioMYpp3j+HUZX78anyqWw17OUityWi/dRnCoyfpPuIi\n" + + "qBGNjMk3JZYz3MmoR9pPGKgzI43EQKBay6+CjZfcQ4Vw7qzW0bUKD2xfLU+ZOeR+\n" + + "jJn5wdBvZHooX8e1en/aLj5h9h9FzhAy3/Sd1ssCgYB1S8tGJvdR2FclAzZeA+hx\n" + + "KntaY/Dm1WSYuaY/ncioEgR3XAa9Hjck/Ml5qgBSeV487CqpFr5tuyueScJh503e\n" + + "rVUbzec+iZfAL3mMZdvTsu5F5s3CIJxC+YHTUb40PbVEwk381vdZgyVdJDikLG8A\n" + + "X1Ix7M97wdRz++f+QY2gIQKBgQCeHaiHt95RU4O7EjT+AVUNPd/fxsht1QgqFpHF\n" + + "rMjEZUXZFyfuWZlX4F9+otR0bruUDbAvzNEsru4zb/Dt7ooegFQk8Ez5OjAbGIT1\n" + + "mz/EDknJsFHoKfHYVdCH1pZQlJNhvm1mv3twbBgeg4fYVKJ+7IfHtPsiYhA9ziS1\n" + + "RucF4wKBgQDJfd1BxBdkeSRIJ/C75iZ4vWWsM/JvMI1L68ZJEWdTqUvyyy9xLWEe\n" + + "8wIGZTv/mnuQhOGSaUUk0fTup7ZwTfmg+hahhCBe5kSh4bav5+knu6yQ7nhwccs8\n" + + "WXeajzno43UHZksae1LP1B3J1+0adxpykCMzWl19XZkxtVkYVi0Q3g==\n" + + "-----END RSA PRIVATE KEY-----"; + + @Test + public void createJWT_is_valid() throws Exception { + String jwt = createJWT("123", PKCS8_PRIVATE_KEY); + Jws parsedJwt = Jwts.parser() + .setSigningKey(getPublicKeyFromString(PKCS8_PUBLIC_KEY)) + .parseClaimsJws(jwt); + assertThat(parsedJwt.getBody().getIssuer(), is("123")); + } + + @Test + public void createJWT_with_pkcs1_is_invalid() { + expectedException.expect(InvalidPrivateKeyException.class); + expectedException.expectMessage(contains("openssl pkcs8 -topk8")); + createJWT("123", PKCS1_PRIVATE_KEY); + } + + @Test + public void createJWT_with_not_base64_is_invalid() { + expectedException.expect(InvalidPrivateKeyException.class); + expectedException.expectMessage(contains("Failed to decode private key")); + createJWT("123", "d£!@!@£!@£"); + } + + private static PublicKey getPublicKeyFromString(final String key) throws GeneralSecurityException { + String publicKeyContent = key.replaceAll("\\n", "") + .replace("-----BEGIN PUBLIC KEY-----", "") + .replace("-----END PUBLIC KEY-----", ""); + + KeyFactory kf = KeyFactory.getInstance("RSA"); + + X509EncodedKeySpec keySpecPKCS8 = new X509EncodedKeySpec(Base64.getDecoder().decode(publicKeyContent)); + + return kf.generatePublic(keySpecPKCS8); + } +} \ No newline at end of file From 96bfe1301b32845aba36714aa85c65a62affc915 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Sun, 2 Feb 2020 21:10:59 +0000 Subject: [PATCH 27/49] Pass api url through to fix GHE --- .../jenkinsci/plugins/github_branch_source/Connector.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 9b0be9f1f..553ef6c84 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -425,7 +425,7 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta if (username != null && !githubApp) { gb.withPassword(username, password); } else if (username != null) { - gb.withOAuthToken(generateAppInstallationToken(username, password), ""); + gb.withOAuthToken(generateAppInstallationToken(username, password, apiUrl), ""); } hub = gb.build(); @@ -437,10 +437,10 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta } @SuppressWarnings("deprecation") // preview features are required for GitHub app integration, GitHub api adds deprecated to all preview methods - private static String generateAppInstallationToken(String appId, String appPrivateKey) { + private static String generateAppInstallationToken(String appId, String appPrivateKey, String apiUrl) { try { String jwtToken = createJWT(appId, appPrivateKey); - GitHub gitHubApp = new GitHubBuilder().withJwtToken(jwtToken).build(); + GitHub gitHubApp = new GitHubBuilder().withEndpoint(apiUrl).withJwtToken(jwtToken).build(); GHApp app = gitHubApp.getApp(); From 5225a5d136baaa6aa41aee3bd5ad4dc914be87ae Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Sat, 1 Feb 2020 16:12:23 +0100 Subject: [PATCH 28/49] Add documentation --- README.md | 10 ++++ docs/github-app.adoc | 111 +++++++++++++++++++++++++++++++++++++++ docs/implementation.adoc | 2 +- 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 docs/github-app.adoc diff --git a/README.md b/README.md index c27c8ff9a..96c3259d7 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,16 @@ The GitHub Branch Source plugin allows you to create a new project based on the GitHub users or organizations. Complete documentation is [hosted by CloudBees](https://docs.cloudbees.com/docs/admin-resources/latest/plugins/github-branch-source). +### Guides + +* [GitHub app authentication](docs/github-app.adoc) +* [Extension points provided by this plugin](docs/implementation.adoc) + +## Extension plugins + +* [github-scm-trait-notification-context](https://github.com/jenkinsci/github-scm-trait-notification-context-plugin) - +allows overriding the `continuous-integration/jenkins/` commit status name. + ## Version History See [the changelog](CHANGELOG.md). diff --git a/docs/github-app.adoc b/docs/github-app.adoc new file mode 100644 index 000000000..dd5cc67bd --- /dev/null +++ b/docs/github-app.adoc @@ -0,0 +1,111 @@ += GitHub app authentication guide + +This guide is targeted to users who want to use a link:https://developer.github.com/v3/apps/[GitHub app] +to authenticate to Jenkins. + +== Why? + +- the link:https://developer.github.com/apps/building-github-apps/understanding-rate-limits-for-github-apps/[rate limit] +for a GitHub app scales with your organization size, whereas a user based token has a limit of 5000 regardless of +how many repositories you have, +- for organization's that have 2fa enforced - no need to manage 2fa tokens for a 'bot' user + +== Getting started + +Before you get started make sure you have the required permissions: + +=== GitHub + +You'll need the permission to create a GitHub app, if you're creating it on a personal account then you can skip this section, +otherwise: + +- organization owner + +or + +- permission to manage GitHub apps has been +link:https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/adding-github-app-managers-in-your-organization[delegated to you]. + +=== Jenkins + +You'll need the permission to create a new credential and update job configuration, the specific permissions are: + +- Credentials/Create +- Job/Configure + +== Creating the GitHub app + +link:https://developer.github.com/apps/building-github-apps/creating-a-github-app/[Follow the GitHub guide for creating an app] + +The only fields you need to fill out (currently) are: + +- Github App name - i.e. `Jenkins - ` +- Homepage URL - your company domain or a github repository +- Webhook URL - your jenkins instance, i.e. `https:///github-webhook/` + +Permissions this plugin uses: + +- Commit statuses - read and write +- Webhooks (optional) - if you want the plugin to manage webhooks for you, read and write + + +Click 'Create GitHub app' + +You now need to generate a private key authenticating to the GitHub app + +Click the 'generate a private key' option. + +After a couple of seconds the key will be downloaded to your downloads folder. + +Now you need to convert the key into a different format that Jenkins can use: + +[source,shell] +---- +openssl pkcs8 -topk8 -inform PEM -outform PEM -in key-in-your-downloads-folder.pem -out converted-github-app.pem -nocrypt +---- + +== Adding the Jenkins credential + +- From the Jenkins main page click 'Credentials' +- Pick your credential store, normally `(global)` +- Click 'Add credentials' + +Fill out the form: + +- Kind: SSH username with private key +- ID: i.e. github-app- +- Username: the github app ID, it can be found in the 'About' section of your GitHub app in the general tab. +- Private key: enter directly, paste the contents of the converted private key +- Passphrase: do not fill this field, it will be ignored +- Click OK + +== Configuring the github organization folder + +See the link:https://docs.cloudbees.com/docs/admin-resources/latest/plugins/github-branch-source[main documentation] +for how to create a GitHub folder. + +- Load the folders configuration page +- Select the GitHub app credentials in the 'Credentials field drop down + +After selecting the credential you should see: + +[quote] +---- +GHApp verified, remaining rate limit: 5000 +---- + +- Click save +- Click 'Scan organization now' +- Click 'Scan organisation log' + +Verify at the bottom of the scan log it says: + +[quote] +---- +Finished: SUCCESS +---- + +=== Help? + +Raise an issue on link:https://issues.jenkins-ci.org/[Jenkins jira] +setting the 'component' to be `github-brance-source-plugin` diff --git a/docs/implementation.adoc b/docs/implementation.adoc index b60d9b871..f1d493080 100644 --- a/docs/implementation.adoc +++ b/docs/implementation.adoc @@ -45,6 +45,6 @@ explicitly apply a `DefaultGitHubNotificationStrategy` to the source context in Duplicate (by equality) strategies are ignored when applied to the source context. ==== Implementations: -https://github.com/steven-foster/github-scm-trait-notification-context[github-scm-trait-notification-context] +https://github.com/jenkinsci/github-scm-trait-notification-context-plugin[github-scm-trait-notification-context] From 42e6826d039fb0b7e2846447b3370a63392b1008 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Sun, 2 Feb 2020 20:22:30 +0100 Subject: [PATCH 29/49] More logging on failure --- .../org/jenkinsci/plugins/github_branch_source/Connector.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 553ef6c84..6073346e1 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -220,7 +220,9 @@ public static FormValidation checkScanCredentials(@CheckForNull Item context, St Connector.release(connector); } } catch (IllegalArgumentException | InvalidPrivateKeyException e) { - return FormValidation.error(e.getMessage()); + String msg = "Exception validating credentials " + CredentialsNameProvider.name(credentials); + LOGGER.log(Level.WARNING, msg, e); + return FormValidation.error(e, msg); } catch (IOException e) { // ignore, never thrown LOGGER.log(Level.WARNING, "Exception validating credentials {0} on {1}", new Object[]{ From 8010d4d27cd486c6cd5d23df61a4e760c6302582 Mon Sep 17 00:00:00 2001 From: Praveen Adusumilli <47391951+adusumillipraveen@users.noreply.github.com> Date: Mon, 3 Feb 2020 15:37:57 +0000 Subject: [PATCH 30/49] Update github-app.adoc --- docs/github-app.adoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/github-app.adoc b/docs/github-app.adoc index dd5cc67bd..3747736ce 100644 --- a/docs/github-app.adoc +++ b/docs/github-app.adoc @@ -45,8 +45,11 @@ The only fields you need to fill out (currently) are: Permissions this plugin uses: -- Commit statuses - read and write -- Webhooks (optional) - if you want the plugin to manage webhooks for you, read and write +- Commit statuses - Read and Write +- Contents: Read-only (to read the Jenkinsfile) +- Metadata: Read-only +- Pull requests: Read-only +- Webhooks (optional) - If you want the plugin to manage webhooks for you, Read and Write Click 'Create GitHub app' From 94157456c917e1a20e6250f3385bb85065c5e91f Mon Sep 17 00:00:00 2001 From: Praveen Adusumilli <47391951+adusumillipraveen@users.noreply.github.com> Date: Tue, 4 Feb 2020 15:29:00 +0000 Subject: [PATCH 31/49] Update github-app.adoc --- docs/github-app.adoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/github-app.adoc b/docs/github-app.adoc index 3747736ce..ec34eae1b 100644 --- a/docs/github-app.adoc +++ b/docs/github-app.adoc @@ -67,6 +67,10 @@ Now you need to convert the key into a different format that Jenkins can use: openssl pkcs8 -topk8 -inform PEM -outform PEM -in key-in-your-downloads-folder.pem -out converted-github-app.pem -nocrypt ---- +== Install the GitHub app + +- From the install app section of newly created app, install the app to your organization. + == Adding the Jenkins credential - From the Jenkins main page click 'Credentials' From df39f0c1833399d06b6f8cb4ea884ba5bd229c1e Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Tue, 4 Feb 2020 20:29:14 +0000 Subject: [PATCH 32/49] Update docs/github-app.adoc Co-Authored-By: Olivier Jacques --- docs/github-app.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/github-app.adoc b/docs/github-app.adoc index ec34eae1b..d2cec6902 100644 --- a/docs/github-app.adoc +++ b/docs/github-app.adoc @@ -9,6 +9,7 @@ to authenticate to Jenkins. for a GitHub app scales with your organization size, whereas a user based token has a limit of 5000 regardless of how many repositories you have, - for organization's that have 2fa enforced - no need to manage 2fa tokens for a 'bot' user +- to improve and tighten security: the Jenkins GitHub app requires a minimum, controlled set of privileges compared to a service user and its personal access token which has a much wider set of privileges == Getting started From 262f07e8d134f9d17905f428b7e4aba812f88859 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Tue, 4 Feb 2020 21:55:38 +0000 Subject: [PATCH 33/49] Update src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java Co-Authored-By: Olivier Jacques --- .../org/jenkinsci/plugins/github_branch_source/Connector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 6073346e1..69f1c6b06 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -113,7 +113,7 @@ protected boolean removeEldestEntry(Map.Entry eldest) { }; private static final Random ENTROPY = new Random(); private static final String SALT = Long.toHexString(ENTROPY.nextLong()); - private static final String ERROR_AUTHENTICATING_GITHUB_APP = "Couldn't find GitHub app installation %s"; + private static final String ERROR_AUTHENTICATING_GITHUB_APP = "Couldn't authenticate with GitHub app ID %s"; private Connector() { throw new IllegalAccessError("Utility class"); From cd4b7952844c2b7cf77dbcf33d1a4fed400db7ee Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Wed, 5 Feb 2020 19:17:44 +0000 Subject: [PATCH 34/49] Create GitHubAppCredential --- pom.xml | 8 +- .../github_branch_source/Connector.java | 49 +----- .../GitHubAppCredential.java | 144 ++++++++++++++++++ .../GitHubSCMNavigator.java | 2 +- .../SSHCheckoutTrait.java | 19 ++- .../GitHubAppCredential/config.jelly | 14 ++ .../github_branch_source/Messages.properties | 2 + 7 files changed, 188 insertions(+), 50 deletions(-) create mode 100644 src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java create mode 100644 src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly diff --git a/pom.xml b/pom.xml index ceb9db148..058a38260 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,13 @@ org.jenkins-ci.plugins credentials - 2.1.18 + 2.2.0 + + + + io.jenkins.temp.jelly + multiline-secrets-ui + 1.0 com.coravy.hudson.plugins.github diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 69f1c6b06..4974a3eb0 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -77,21 +77,14 @@ import org.apache.commons.lang.StringUtils; import org.jenkinsci.plugins.gitclient.GitClient; import org.jenkinsci.plugins.github.config.GitHubServerConfig; -import org.kohsuke.accmod.Restricted; -import org.kohsuke.accmod.restrictions.NoExternalUse; -import org.kohsuke.github.GHApp; -import org.kohsuke.github.GHAppInstallation; -import org.kohsuke.github.GHAppInstallationToken; import org.kohsuke.github.GitHub; import org.kohsuke.github.GitHubBuilder; -import org.kohsuke.github.HttpConnector; import org.kohsuke.github.RateLimitHandler; import org.kohsuke.github.extras.OkHttpConnector; import static com.cloudbees.plugins.credentials.CredentialsMatchers.anyOf; import static com.cloudbees.plugins.credentials.CredentialsMatchers.instanceOf; import static java.util.logging.Level.FINE; -import static org.jenkinsci.plugins.github_branch_source.JwtHelper.createJWT; /** * Utilities that could perhaps be moved into {@code github-api}. @@ -113,7 +106,6 @@ protected boolean removeEldestEntry(Map.Entry eldest) { }; private static final Random ENTROPY = new Random(); private static final String SALT = Long.toHexString(ENTROPY.nextLong()); - private static final String ERROR_AUTHENTICATING_GITHUB_APP = "Couldn't authenticate with GitHub app ID %s"; private Connector() { throw new IllegalAccessError("Utility class"); @@ -206,7 +198,7 @@ public static FormValidation checkScanCredentials(@CheckForNull Item context, St GitHub connector = Connector.connect(apiUri, credentials); try { try { - boolean githubAppAuthentication = credentials instanceof SSHUserPrivateKey; + boolean githubAppAuthentication = credentials instanceof GitHubAppCredential; if (githubAppAuthentication) { int remaining = connector.getRateLimit().getRemaining(); return FormValidation.ok("GHApp verified, remaining rate limit: %d", remaining); @@ -327,9 +319,6 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta } else if (credentials instanceof StandardUsernamePasswordCredentials) { StandardUsernamePasswordCredentials c = (StandardUsernamePasswordCredentials) credentials; hash = Util.getDigestOf(c.getPassword().getPlainText() + SALT); - } else if (credentials instanceof SSHUserPrivateKey) { - SSHUserPrivateKey c = (SSHUserPrivateKey) credentials; - hash = Util.getDigestOf(c.getPrivateKeys().get(0) + SALT); } else { // TODO OAuth support throw new IOException("Unsupported credential type: " + credentials.getClass().getName()); @@ -352,7 +341,6 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta String password; String hash; String authHash; - boolean githubApp = false; Jenkins jenkins = Jenkins.get(); if (credentials == null) { username = null; @@ -365,14 +353,6 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta password = c.getPassword().getPlainText(); hash = Util.getDigestOf(password + SALT); // want to ensure pooling by credential authHash = Util.getDigestOf(password + "::" + jenkins.getLegacyInstanceId()); - } else if (credentials instanceof SSHUserPrivateKey) { - SSHUserPrivateKey c = (SSHUserPrivateKey) credentials; - username = c.getUsername(); - password = c.getPrivateKeys().get(0); - hash = Util.getDigestOf(password + SALT); - authHash = Util.getDigestOf(password + "::" + jenkins.getLegacyInstanceId()); - - githubApp = true; } else { // TODO OAuth support throw new IOException("Unsupported credential type: " + credentials.getClass().getName()); @@ -424,10 +404,8 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta gb.withConnector(new OkHttpConnector(new OkUrlFactory(client))); - if (username != null && !githubApp) { + if (username != null) { gb.withPassword(username, password); - } else if (username != null) { - gb.withOAuthToken(generateAppInstallationToken(username, password, apiUrl), ""); } hub = gb.build(); @@ -438,29 +416,6 @@ public static void checkApiUrlValidity(@Nonnull GitHub gitHub, @CheckForNull Sta } } - @SuppressWarnings("deprecation") // preview features are required for GitHub app integration, GitHub api adds deprecated to all preview methods - private static String generateAppInstallationToken(String appId, String appPrivateKey, String apiUrl) { - try { - String jwtToken = createJWT(appId, appPrivateKey); - GitHub gitHubApp = new GitHubBuilder().withEndpoint(apiUrl).withJwtToken(jwtToken).build(); - - GHApp app = gitHubApp.getApp(); - - List appInstallations = app.listInstallations().asList(); - if (!appInstallations.isEmpty()) { - GHAppInstallation appInstallation = appInstallations.get(0); - GHAppInstallationToken appInstallationToken = appInstallation - .createToken(appInstallation.getPermissions()) - .create(); - - return appInstallationToken.getToken(); - } - } catch (IOException e) { - throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId), e); - } - throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId)); - } - public static void release(@CheckForNull GitHub hub) { if (hub == null) { return; diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java new file mode 100644 index 000000000..af9383c50 --- /dev/null +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java @@ -0,0 +1,144 @@ +package org.jenkinsci.plugins.github_branch_source; + +import com.cloudbees.plugins.credentials.CredentialsScope; +import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; +import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import hudson.Extension; +import hudson.Util; +import hudson.util.Secret; +import java.io.IOException; +import java.util.List; +import org.kohsuke.github.GHApp; +import org.kohsuke.github.GHAppInstallation; +import org.kohsuke.github.GHAppInstallationToken; +import org.kohsuke.github.GitHub; +import org.kohsuke.github.GitHubBuilder; +import org.kohsuke.stapler.DataBoundConstructor; + +import static org.jenkinsci.plugins.github_branch_source.JwtHelper.createJWT; + +public class GitHubAppCredential extends BaseStandardCredentials implements StandardUsernamePasswordCredentials { + + private static final String ERROR_AUTHENTICATING_GITHUB_APP = "Couldn't authenticate with GitHub app ID %s"; + + @NonNull + private final String appID; + + @NonNull + private final Secret privateKey; + + private String apiUrl; + + /** + * Constructor. + * + * @param scope the credentials scope + * @param id the ID or {@code null} to generate a new one. + * @param description the description. + * @param appID the username. + * @param privateKey the password. + */ + @DataBoundConstructor + @SuppressWarnings("unused") // by stapler + public GitHubAppCredential( + CredentialsScope scope, + String id, + @CheckForNull String description, + @NonNull String appID, + @NonNull Secret privateKey + ) { + super(scope, id, description); + this.appID = appID; + this.privateKey = privateKey; + } + + public String getApiUrl() { + return apiUrl; + } + + public void setApiUrl(String apiUrl) { + this.apiUrl = apiUrl; + } + + @NonNull + public String getAppID() { + return appID; + } + + @NonNull + public Secret getPrivateKey() { + return privateKey; + } + + @SuppressWarnings("deprecation") // preview features are required for GitHub app integration, GitHub api adds deprecated to all preview methods + static String generateAppInstallationToken(String appId, String appPrivateKey, String apiUrl) { + try { + String jwtToken = createJWT(appId, appPrivateKey); + GitHub gitHubApp = new GitHubBuilder().withEndpoint(apiUrl).withJwtToken(jwtToken).build(); + + GHApp app = gitHubApp.getApp(); + + List appInstallations = app.listInstallations().asList(); + if (!appInstallations.isEmpty()) { + GHAppInstallation appInstallation = appInstallations.get(0); + GHAppInstallationToken appInstallationToken = appInstallation + .createToken(appInstallation.getPermissions()) + .create(); + + return appInstallationToken.getToken(); + } + } catch (IOException e) { + throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId), e); + } + throw new IllegalArgumentException(String.format(ERROR_AUTHENTICATING_GITHUB_APP, appId)); + } + + /** + * {@inheritDoc} + */ + @NonNull + @Override + public Secret getPassword() { + if (Util.fixEmpty(apiUrl) == null) { + apiUrl = "https://api.github.com"; + } + + String appInstallationToken = generateAppInstallationToken(appID, privateKey.getPlainText(), apiUrl); + + return Secret.fromString(appInstallationToken); + } + + /** + * {@inheritDoc} + */ + @NonNull + @Override + public String getUsername() { + return appID; + } + + /** + * {@inheritDoc} + */ + @Extension + public static class DescriptorImpl extends BaseStandardCredentialsDescriptor { + + /** + * {@inheritDoc} + */ + @Override + public String getDisplayName() { + return Messages.GitHubAppCredential_displayName(); + } + + /** + * {@inheritDoc} + */ + @Override + public String getIconClassName() { + return "icon-github-logo"; + } + } +} diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 122424d13..eed2b8195 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -934,7 +934,7 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru SourceFactory sourceFactory = new SourceFactory(request); WitnessImpl witness = new WitnessImpl(listener); - boolean githubAppAuthentication = credentials instanceof SSHUserPrivateKey; + boolean githubAppAuthentication = credentials instanceof GitHubAppCredential; if (!github.isAnonymous() && !githubAppAuthentication) { GHMyself myself; try { diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java index aa583aa34..14cdc16e9 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java @@ -35,12 +35,12 @@ import hudson.Util; import hudson.model.Item; import hudson.model.Queue; -import hudson.model.queue.Tasks; import hudson.plugins.git.GitSCM; import hudson.scm.SCM; import hudson.security.ACL; import hudson.util.FormValidation; import hudson.util.ListBoxModel; +import java.util.Objects; import jenkins.model.Jenkins; import jenkins.plugins.git.GitSCMBuilder; import jenkins.scm.api.SCMSource; @@ -105,6 +105,23 @@ protected void decorateBuilder(SCMBuilder builder) { ((GitHubSCMBuilder)builder).withCredentials(credentialsId, GitHubSCMBuilder.SSH); } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SSHCheckoutTrait that = (SSHCheckoutTrait) o; + return Objects.equals(credentialsId, that.credentialsId); + } + + @Override + public int hashCode() { + return Objects.hash(credentialsId); + } + /** * Our descriptor. */ diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly new file mode 100644 index 000000000..953a7ec07 --- /dev/null +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly @@ -0,0 +1,14 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties index 72b7e2bac..b609ef7f7 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties @@ -66,3 +66,5 @@ ExcludeArchivedRepositoriesTrait.displayName=Exclude archived repositories GitHubSCMNavigator.general=General GitHubSCMNavigator.withinRepository=Within repository + +GitHubAppCredential.displayName=GitHub app \ No newline at end of file From 9e7de1c20d1aeacbc3666a17c12846e6534ef6b7 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Wed, 5 Feb 2020 19:32:22 +0000 Subject: [PATCH 35/49] Revert unneeded changes --- docs/github-app.adoc | 6 +++--- .../github_branch_source/Connector.java | 7 ++----- .../GitHubAppCredential.java | 9 --------- .../SSHCheckoutTrait.java | 19 +------------------ .../help-credentialsId.html | 15 +++++---------- .../GitHubSCMSource/help-credentialsId.html | 11 ----------- 6 files changed, 11 insertions(+), 56 deletions(-) diff --git a/docs/github-app.adoc b/docs/github-app.adoc index d2cec6902..e62480213 100644 --- a/docs/github-app.adoc +++ b/docs/github-app.adoc @@ -80,10 +80,10 @@ openssl pkcs8 -topk8 -inform PEM -outform PEM -in key-in-your-downloads-folder.p Fill out the form: -- Kind: SSH username with private key +- Kind: GitHub app - ID: i.e. github-app- -- Username: the github app ID, it can be found in the 'About' section of your GitHub app in the general tab. -- Private key: enter directly, paste the contents of the converted private key +- App ID: the github app ID, it can be found in the 'About' section of your GitHub app in the general tab. +- Key: click add, paste the contents of the converted private key - Passphrase: do not fill this field, it will be ignored - Click OK diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 4974a3eb0..645b4e06b 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -25,7 +25,6 @@ package org.jenkinsci.plugins.github_branch_source; import com.cloudbees.jenkins.GitHubWebHook; -import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey; import com.cloudbees.plugins.credentials.CredentialsMatcher; import com.cloudbees.plugins.credentials.CredentialsMatchers; import com.cloudbees.plugins.credentials.CredentialsNameProvider; @@ -463,10 +462,8 @@ private static void unused(@Nonnull GitHub hub) { } private static CredentialsMatcher githubScanCredentialsMatcher() { - return anyOf( - instanceOf(StandardUsernamePasswordCredentials.class), - instanceOf(SSHUserPrivateKey.class) - ); + // TODO OAuth credentials + return CredentialsMatchers.anyOf(CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class)); } static List githubDomainRequirements(String apiUri) { diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java index af9383c50..f2e624ec8 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java @@ -31,15 +31,6 @@ public class GitHubAppCredential extends BaseStandardCredentials implements Stan private String apiUrl; - /** - * Constructor. - * - * @param scope the credentials scope - * @param id the ID or {@code null} to generate a new one. - * @param description the description. - * @param appID the username. - * @param privateKey the password. - */ @DataBoundConstructor @SuppressWarnings("unused") // by stapler public GitHubAppCredential( diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java index 14cdc16e9..aa583aa34 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/SSHCheckoutTrait.java @@ -35,12 +35,12 @@ import hudson.Util; import hudson.model.Item; import hudson.model.Queue; +import hudson.model.queue.Tasks; import hudson.plugins.git.GitSCM; import hudson.scm.SCM; import hudson.security.ACL; import hudson.util.FormValidation; import hudson.util.ListBoxModel; -import java.util.Objects; import jenkins.model.Jenkins; import jenkins.plugins.git.GitSCMBuilder; import jenkins.scm.api.SCMSource; @@ -105,23 +105,6 @@ protected void decorateBuilder(SCMBuilder builder) { ((GitHubSCMBuilder)builder).withCredentials(credentialsId, GitHubSCMBuilder.SSH); } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - SSHCheckoutTrait that = (SSHCheckoutTrait) o; - return Objects.equals(credentialsId, that.credentialsId); - } - - @Override - public int hashCode() { - return Objects.hash(credentialsId); - } - /** * Our descriptor. */ diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html index 322f0a622..a77b93fbd 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator/help-credentialsId.html @@ -3,16 +3,11 @@ Credentials used to scan branches and pull requests, check out sources and mark commit statuses.

- The following credential types are supported: -
    -
  • - "Username with password" -
  • -
  • - "SSH Username with private key" - this is for authenticating as a GitHub app. - The username should be the 'GitHub app ID'. -
  • -
+

+ Note that only "username with password" credentials are supported. + Existing credentials of other kinds will be filtered out. This is because Jenkins + uses the GitHub API, which does not support other ways of authentication. +

If none is given, only the public repositories will be scanned, and commit status will not be set on GitHub. diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html index df36ebcba..a77b93fbd 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource/help-credentialsId.html @@ -3,17 +3,6 @@ Credentials used to scan branches and pull requests, check out sources and mark commit statuses.

- The following credential types are supported: -
    -
  • - "Username with password" -
  • -
  • - "SSH Username with private key" - this is for authenticating as a GitHub app. - The username should be the 'GitHub app ID'. -
  • -
-

Note that only "username with password" credentials are supported. Existing credentials of other kinds will be filtered out. This is because Jenkins From e2c9374023cb236808a225c9d904758a43489c3d Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Wed, 5 Feb 2020 20:15:28 +0000 Subject: [PATCH 36/49] Add GHE support --- .../GitHubAppCredential.java | 65 ++++++++++++++++--- .../GitHubSCMNavigator.java | 4 ++ .../GitHubAppCredential/config.jelly | 16 +++++ .../GitHubAppCredential/help-apiUri.html | 3 + 4 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-apiUri.html diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java index f2e624ec8..107fbb360 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java @@ -7,16 +7,24 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.Util; +import hudson.util.FormValidation; +import hudson.util.ListBoxModel; import hudson.util.Secret; import java.io.IOException; import java.util.List; +import org.kohsuke.accmod.Restricted; +import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.github.GHApp; import org.kohsuke.github.GHAppInstallation; import org.kohsuke.github.GHAppInstallationToken; import org.kohsuke.github.GitHub; import org.kohsuke.github.GitHubBuilder; import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; +import org.kohsuke.stapler.QueryParameter; +import org.kohsuke.stapler.verb.POST; +import static org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.DescriptorImpl.getPossibleApiUriItems; import static org.jenkinsci.plugins.github_branch_source.JwtHelper.createJWT; public class GitHubAppCredential extends BaseStandardCredentials implements StandardUsernamePasswordCredentials { @@ -29,7 +37,7 @@ public class GitHubAppCredential extends BaseStandardCredentials implements Stan @NonNull private final Secret privateKey; - private String apiUrl; + private String apiUri; @DataBoundConstructor @SuppressWarnings("unused") // by stapler @@ -45,12 +53,13 @@ public GitHubAppCredential( this.privateKey = privateKey; } - public String getApiUrl() { - return apiUrl; + public String getApiUri() { + return apiUri; } - public void setApiUrl(String apiUrl) { - this.apiUrl = apiUrl; + @DataBoundSetter + public void setApiUri(String apiUri) { + this.apiUri = apiUri; } @NonNull @@ -92,11 +101,11 @@ static String generateAppInstallationToken(String appId, String appPrivateKey, S @NonNull @Override public Secret getPassword() { - if (Util.fixEmpty(apiUrl) == null) { - apiUrl = "https://api.github.com"; + if (Util.fixEmpty(apiUri) == null) { + apiUri = "https://api.github.com"; } - String appInstallationToken = generateAppInstallationToken(appID, privateKey.getPlainText(), apiUrl); + String appInstallationToken = generateAppInstallationToken(appID, privateKey.getPlainText(), apiUri); return Secret.fromString(appInstallationToken); } @@ -131,5 +140,45 @@ public String getDisplayName() { public String getIconClassName() { return "icon-github-logo"; } + + @SuppressWarnings("unused") // jelly + public boolean isApiUriSelectable() { + return !GitHubConfiguration.get().getEndpoints().isEmpty(); + } + + /** + * Returns the available GitHub endpoint items. + * + * @return the available GitHub endpoint items. + */ + @SuppressWarnings("unused") // stapler + @Restricted(NoExternalUse.class) // stapler + public ListBoxModel doFillApiUriItems() { + return getPossibleApiUriItems(); + } + + @POST + @SuppressWarnings("unused") // stapler + @Restricted(NoExternalUse.class) // stapler + public FormValidation doTestConnection( + @QueryParameter("appID") final String appID, + @QueryParameter("privateKey") final String privateKey, + @QueryParameter("apiUri") final String apiUri + + ) { + GitHubAppCredential gitHubAppCredential = new GitHubAppCredential( + CredentialsScope.GLOBAL, "test-id-not-being-saved", null, + appID, Secret.fromString(privateKey) + ); + gitHubAppCredential.setApiUri(apiUri); + + try { + GitHub connect = Connector.connect(apiUri, gitHubAppCredential); + + return FormValidation.ok("Success, Remaining rate limit: " + connect.getRateLimit().getRemaining()); + } catch (Exception e) { + return FormValidation.error(e, String.format(ERROR_AUTHENTICATING_GITHUB_APP, appID)); + } + } } } diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index eed2b8195..5d58b8cea 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -1416,6 +1416,10 @@ public ListBoxModel doFillCredentialsIdItems(@CheckForNull @AncestorInPath Item @Restricted(NoExternalUse.class) // stapler @SuppressWarnings("unused") // stapler public ListBoxModel doFillApiUriItems() { + return getPossibleApiUriItems(); + } + + static ListBoxModel getPossibleApiUriItems() { ListBoxModel result = new ListBoxModel(); result.add("GitHub", ""); for (Endpoint e : GitHubConfiguration.get().getEndpoints()) { diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly index 953a7ec07..7544d9d58 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly @@ -4,6 +4,18 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-apiUri.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-apiUri.html new file mode 100644 index 000000000..72fce8569 --- /dev/null +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-apiUri.html @@ -0,0 +1,3 @@ +

+ GitHub API endpoint such as https://github.example.com/api/v3/. +

\ No newline at end of file From c311b36f15001b461b56fbfca855042c99cf736c Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Wed, 5 Feb 2020 20:17:02 +0000 Subject: [PATCH 37/49] Revert change back for non gh app --- .../org/jenkinsci/plugins/github_branch_source/Connector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index 645b4e06b..cf501e5e0 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -203,7 +203,7 @@ public static FormValidation checkScanCredentials(@CheckForNull Item context, St return FormValidation.ok("GHApp verified, remaining rate limit: %d", remaining); } - return FormValidation.ok("User %s", connector.isCredentialValid()); + return FormValidation.ok("User %s", connector.getMyself().getLogin()); } catch (Exception e) { return FormValidation.error("Invalid credentials: %s", e.getMessage()); } From ad2e0ca954e7b18bc9a99f11a31c207c4f3a6553 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Wed, 5 Feb 2020 21:34:43 +0000 Subject: [PATCH 38/49] Add more help text --- .../GitHubAppCredential/help-appID.html | 3 +++ .../GitHubAppCredential/help-privateKey.html | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-appID.html create mode 100644 src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-privateKey.html diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-appID.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-appID.html new file mode 100644 index 000000000..d85fa8314 --- /dev/null +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-appID.html @@ -0,0 +1,3 @@ +

+ GitHub app ID, can be found on the App's settings, on the General page in the About section +

\ No newline at end of file diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-privateKey.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-privateKey.html new file mode 100644 index 000000000..00374b9d8 --- /dev/null +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-privateKey.html @@ -0,0 +1,6 @@ +

+ Private key for authenticating to GitHub with, it must be in PKCS#8 format, GitHub will give it to you in PKCS#1. +

+

+ You can convert it with openssl pkcs8 -topk8 -inform PEM -outform PEM -in current-key.pem -out new-key.pem -nocrypt +

\ No newline at end of file From d2fe5026edd5ec3c3cdae3414f2a23280b99c372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scheibe?= Date: Mon, 3 Feb 2020 21:45:35 +0100 Subject: [PATCH 39/49] Fix typos --- CHANGELOG.md | 2 +- .../plugins/github_branch_source/Endpoint.java | 4 ++-- .../github_branch_source/GitHubSCMSource.java | 12 ++++++------ .../github_branch_source/PullRequestSCMRevision.java | 2 +- .../github_branch_source/PushGHEventSubscriber.java | 2 +- .../github_branch_source/RepositoryUriResolver.java | 2 +- src/main/webapp/github-scm-source.js | 2 +- .../ApiRateLimitCheckerTest.java | 6 +++--- .../BranchDiscoveryTraitTest.java | 2 +- .../ForkPullRequestDiscoveryTraitTest.java | 6 +++--- .../GitHubSCMFileSystemTest.java | 2 +- .../GithubSCMSourceTagsTest.java | 2 +- .../OriginPullRequestDiscoveryTraitTest.java | 6 +++--- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82265ac52..a9200950a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,7 @@ are in-flight (dependency on Jenkins Core v2.167) ## Version 2.5.3 Release date: 2019-05-23 -- [JENKINS-57583](https://issues.jenkins-ci.org/browse/JENKINS-57583): Fixed compatibility with the "Ignore target brach" setting +- [JENKINS-57583](https://issues.jenkins-ci.org/browse/JENKINS-57583): Fixed compatibility with the "Ignore target branch" setting - [JENKINS-57371](https://issues.jenkins-ci.org/browse/JENKINS-57371): Added graceful fallback to cloning for PRs when needed diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java index f5ba146d6..de6cef566 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Endpoint.java @@ -129,9 +129,9 @@ public int hashCode() { } @Extension - public static class DesciptorImpl extends Descriptor { + public static class DescriptorImpl extends Descriptor { - private static final Logger LOGGER = Logger.getLogger(DesciptorImpl.class.getName()); + private static final Logger LOGGER = Logger.getLogger(DescriptorImpl.class.getName()); @Override public String getDisplayName() { diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java index 711eb39c2..fe8c151ea 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java @@ -1016,7 +1016,7 @@ public SCMSourceCriteria.Probe create(@NonNull BranchSCMHead head, // Branches and tags are contained only the current repo, PRs go across forks // FileNotFoundException can occur in a number of situations // When this happens, it is not ideal behavior but it is better to let the PR be orphaned - // and the the orphan stratgy control the result than for this error to stop scanning + // and the orphan strategy control the result than for this error to stop scanning // (For Org scanning this is particularly important.) // If some more general IO exception is thrown, we will still fail. @@ -2343,7 +2343,7 @@ protected Iterable create() { if (pullRequest.getState() != GHIssueState.OPEN) { return Collections.emptyList(); } - return new CacheUdatingIterable(Collections.singletonList(pullRequest)); + return new CacheUpdatingIterable(Collections.singletonList(pullRequest)); } Set branchNames = request.getRequestedOriginBranchNames(); if (branchNames != null && branchNames.size() == 1) { // TODO flag to check PRs are all origin PRs @@ -2354,14 +2354,14 @@ protected Iterable create() { request.listener().getLogger().format( "%n Getting remote pull requests from branch %s...%n", branchName ); - return new CacheUdatingIterable(repo.queryPullRequests() + return new CacheUpdatingIterable(repo.queryPullRequests() .state(GHIssueState.OPEN) .head(repo.getOwnerName() + ":" + branchName) .list()); } request.listener().getLogger().format("%n Getting remote pull requests...%n"); fullScanRequested = true; - return new CacheUdatingIterable(LazyPullRequests.this.repo.queryPullRequests() + return new CacheUpdatingIterable(LazyPullRequests.this.repo.queryPullRequests() .state(GHIssueState.OPEN) .list()); } catch (IOException | InterruptedException e) { @@ -2385,12 +2385,12 @@ public void close() throws IOException { } } - private class CacheUdatingIterable extends SinglePassIterable { + private class CacheUpdatingIterable extends SinglePassIterable { /** * A map of all fully populated {@link GHUser} entries we have fetched, keyed by {@link GHUser#getLogin()}. */ private Map users = new HashMap<>(); - CacheUdatingIterable(Iterable delegate) { + CacheUpdatingIterable(Iterable delegate) { super(delegate); } diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevision.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevision.java index 5efb99056..2ad6c0230 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevision.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/PullRequestSCMRevision.java @@ -114,7 +114,7 @@ public boolean equivalent(ChangeRequestSCMRevision o) { } PullRequestSCMRevision other = (PullRequestSCMRevision) o; - // JENKINS-57583 - Equivalent is used to make decisiions about when to build. + // JENKINS-57583 - Equivalent is used to make decisions about when to build. // mergeHash is an implementation detail of github, generated from base and target // If only mergeHash changes we do not consider it a different revision return getHead().equals(other.getHead()) && pullHash.equals(other.pullHash); diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java index d88144700..582bedfdc 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/PushGHEventSubscriber.java @@ -331,7 +331,7 @@ && isApiMatch(((GitHubSCMSource) source).getApiUri()) // // Event consumers are supposed to *not* trust the details reported by an event, it's just a hint. // All we really want is that we report enough of a head to provide the head.getName() - // then the event consumer is supposed to turn arround and do a fetch(..., event, ...) + // then the event consumer is supposed to turn around and do a fetch(..., event, ...) // and as GitHubSCMSourceRequest strips out the timestamp in calculating the requested // tag names, we have a winner. // diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/RepositoryUriResolver.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/RepositoryUriResolver.java index 2a75e048d..b91cf15d3 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/RepositoryUriResolver.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/RepositoryUriResolver.java @@ -30,7 +30,7 @@ import java.net.URL; /** - * Resolves the URI of a GitHub repositort from the API URI, owner and repository name. + * Resolves the URI of a GitHub repository from the API URI, owner and repository name. */ public abstract class RepositoryUriResolver { diff --git a/src/main/webapp/github-scm-source.js b/src/main/webapp/github-scm-source.js index 1025f39a0..6774e541e 100644 --- a/src/main/webapp/github-scm-source.js +++ b/src/main/webapp/github-scm-source.js @@ -37,7 +37,7 @@ Behaviour.specify("input[name$=_configuredByUrlRadio]", 'GitHubSCMSourceRadioCon if (document.createEvent) { var oEvent = document.createEvent("HTMLEvents"); oEvent.initEvent("change"); - // Gets the first Jelly entry afte the hidden value + // Gets the first Jelly entry after the hidden value var repoOwner = getNthParent(e, 3).nextElementSibling.nextElementSibling.childNodes[2].firstElementChild; // if the first entry is a select for API URI, gets the following one (each Jelly entry has 3 elements) if (repoOwner == null || repoOwner.tagName == "SELECT") { diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java index 545df4914..dacbbbfc4 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ApiRateLimitCheckerTest.java @@ -404,7 +404,7 @@ public void OnOverThrottleTimingRateLimitCheck() throws Exception { ApiRateLimitChecker.ThrottleOnOver.checkApiRateLimit(listener, github); } - //should be no ouput + //should be no output assertEquals(0, countOfOutputLinesContaining("Sleeping")); // check rate limit to hit the next 5 scenarios @@ -525,9 +525,9 @@ public void NormalizeExpectedIdealOverTime() throws Exception { // Expect a triggered throttle for normalize assertEquals(12, countOfOutputLinesContaining("Current quota")); - //Making sure the budgets are correct + // Making sure the budgets are correct assertEquals(12, countOfOutputLinesContaining("0 under budget")); - // no occurences of sleeping + // no occurrences of sleeping assertEquals(0, countOfOutputLines(m -> m.matches("[sS]leeping"))); } diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java index 0343fbe18..890a83953 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/BranchDiscoveryTraitTest.java @@ -23,7 +23,7 @@ public class BranchDiscoveryTraitTest { public static JenkinsRule j = new JenkinsRule(); @Test - public void given__disoverAll__when__appliedToContext__then__noFilter() throws Exception { + public void given__discoverAll__when__appliedToContext__then__noFilter() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.wantBranches(), is(false)); assumeThat(ctx.wantPRs(), is(false)); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java index 8579947eb..853db3ee3 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTraitTest.java @@ -26,7 +26,7 @@ public void xstream() throws Exception { } @Test - public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCorrect() throws Exception { + public void given__discoverHeadMerge__when__appliedToContext__then__strategiesCorrect() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.wantBranches(), is(false)); assumeThat(ctx.wantPRs(), is(false)); @@ -51,7 +51,7 @@ public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCor } @Test - public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorrect() throws Exception { + public void given__discoverHeadOnly__when__appliedToContext__then__strategiesCorrect() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.wantBranches(), is(false)); assumeThat(ctx.wantPRs(), is(false)); @@ -76,7 +76,7 @@ public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorr } @Test - public void given__disoverMergeOnly__when__appliedToContext__then__strategiesCorrect() throws Exception { + public void given__discoverMergeOnly__when__appliedToContext__then__strategiesCorrect() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.wantBranches(), is(false)); assumeThat(ctx.wantPRs(), is(false)); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java index ff40011a6..93f3c5ee7 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMFileSystemTest.java @@ -232,7 +232,7 @@ public void readFileFromDir() throws Exception { // the checkout may have "fixed" line endings that we needed to handle. // The problem with the raw url data is that it can get out of sync when from the actual content. // The GitHub API info stays sync'd and correct, so now GHContent.read() pulls from mime encoded data - // in the GHContent record itself. Keeping this for refence in case it changes again. + // in the GHContent record itself. Keeping this for reference in case it changes again. // try (InputStream inputStream = getClass().getResourceAsStream("/raw/__files/body-fu-bar.txt-b4k4I.txt")) { // if (inputStream != null) { // expected = IOUtils.toString(inputStream, StandardCharsets.US_ASCII); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceTagsTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceTagsTest.java index 3217072e6..d08bba084 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceTagsTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GithubSCMSourceTagsTest.java @@ -149,7 +149,7 @@ public void testExistingMultipleTags() throws IOException { } @Test - public void testExistingMultipleTagsGHFileNotFoundExceptionIteratable() throws IOException { + public void testExistingMultipleTagsGHFileNotFoundExceptionIterable() throws IOException { // Scenario: Requesting multiple tags but a FileNotFound is thrown // on the first returning the iterator and then an IO error is thrown on the iterator creation SCMHeadObserver mockSCMHeadObserver = Mockito.mock(SCMHeadObserver.class); diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java index 9b3f9fe5b..e4fb560cd 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/OriginPullRequestDiscoveryTraitTest.java @@ -20,7 +20,7 @@ public class OriginPullRequestDiscoveryTraitTest { @Test - public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCorrect() throws Exception { + public void given__discoverHeadMerge__when__appliedToContext__then__strategiesCorrect() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.wantBranches(), is(false)); assumeThat(ctx.wantPRs(), is(false)); @@ -44,7 +44,7 @@ public void given__disoverHeadMerge__when__appliedToContext__then__strategiesCor } @Test - public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorrect() throws Exception { + public void given__discoverHeadOnly__when__appliedToContext__then__strategiesCorrect() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.wantBranches(), is(false)); assumeThat(ctx.wantPRs(), is(false)); @@ -68,7 +68,7 @@ public void given__disoverHeadOnly__when__appliedToContext__then__strategiesCorr } @Test - public void given__disoverMergeOnly__when__appliedToContext__then__strategiesCorrect() throws Exception { + public void given__discoverMergeOnly__when__appliedToContext__then__strategiesCorrect() throws Exception { GitHubSCMSourceContext ctx = new GitHubSCMSourceContext(null, SCMHeadObserver.none()); assumeThat(ctx.wantBranches(), is(false)); assumeThat(ctx.wantPRs(), is(false)); From 07dc6a6a74b033ab4a01fc64f6ff4fb72501b0f1 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 6 Feb 2020 07:40:41 +0000 Subject: [PATCH 40/49] Rename credential class So that JCasC symbol name is resolved to: githubApp and not githubAppCredential --- .../jenkinsci/plugins/github_branch_source/Connector.java | 4 +--- ...GitHubAppCredential.java => GitHubAppCredentials.java} | 8 ++++---- .../plugins/github_branch_source/GitHubSCMNavigator.java | 3 +-- .../config.jelly | 0 .../help-apiUri.html | 0 .../help-appID.html | 0 .../help-privateKey.html | 0 .../plugins/github_branch_source/Messages.properties | 2 +- 8 files changed, 7 insertions(+), 10 deletions(-) rename src/main/java/org/jenkinsci/plugins/github_branch_source/{GitHubAppCredential.java => GitHubAppCredentials.java} (95%) rename src/main/resources/org/jenkinsci/plugins/github_branch_source/{GitHubAppCredential => GitHubAppCredentials}/config.jelly (100%) rename src/main/resources/org/jenkinsci/plugins/github_branch_source/{GitHubAppCredential => GitHubAppCredentials}/help-apiUri.html (100%) rename src/main/resources/org/jenkinsci/plugins/github_branch_source/{GitHubAppCredential => GitHubAppCredentials}/help-appID.html (100%) rename src/main/resources/org/jenkinsci/plugins/github_branch_source/{GitHubAppCredential => GitHubAppCredentials}/help-privateKey.html (100%) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java index cf501e5e0..37e919333 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java @@ -81,8 +81,6 @@ import org.kohsuke.github.RateLimitHandler; import org.kohsuke.github.extras.OkHttpConnector; -import static com.cloudbees.plugins.credentials.CredentialsMatchers.anyOf; -import static com.cloudbees.plugins.credentials.CredentialsMatchers.instanceOf; import static java.util.logging.Level.FINE; /** @@ -197,7 +195,7 @@ public static FormValidation checkScanCredentials(@CheckForNull Item context, St GitHub connector = Connector.connect(apiUri, credentials); try { try { - boolean githubAppAuthentication = credentials instanceof GitHubAppCredential; + boolean githubAppAuthentication = credentials instanceof GitHubAppCredentials; if (githubAppAuthentication) { int remaining = connector.getRateLimit().getRemaining(); return FormValidation.ok("GHApp verified, remaining rate limit: %d", remaining); diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java similarity index 95% rename from src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java rename to src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java index 107fbb360..4ff804e2c 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials.java @@ -27,7 +27,7 @@ import static org.jenkinsci.plugins.github_branch_source.GitHubSCMNavigator.DescriptorImpl.getPossibleApiUriItems; import static org.jenkinsci.plugins.github_branch_source.JwtHelper.createJWT; -public class GitHubAppCredential extends BaseStandardCredentials implements StandardUsernamePasswordCredentials { +public class GitHubAppCredentials extends BaseStandardCredentials implements StandardUsernamePasswordCredentials { private static final String ERROR_AUTHENTICATING_GITHUB_APP = "Couldn't authenticate with GitHub app ID %s"; @@ -41,7 +41,7 @@ public class GitHubAppCredential extends BaseStandardCredentials implements Stan @DataBoundConstructor @SuppressWarnings("unused") // by stapler - public GitHubAppCredential( + public GitHubAppCredentials( CredentialsScope scope, String id, @CheckForNull String description, @@ -130,7 +130,7 @@ public static class DescriptorImpl extends BaseStandardCredentialsDescriptor { */ @Override public String getDisplayName() { - return Messages.GitHubAppCredential_displayName(); + return Messages.GitHubAppCredentials_displayName(); } /** @@ -166,7 +166,7 @@ public FormValidation doTestConnection( @QueryParameter("apiUri") final String apiUri ) { - GitHubAppCredential gitHubAppCredential = new GitHubAppCredential( + GitHubAppCredentials gitHubAppCredential = new GitHubAppCredentials( CredentialsScope.GLOBAL, "test-id-not-being-saved", null, appID, Secret.fromString(privateKey) ); diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 5d58b8cea..ede94cf55 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -25,7 +25,6 @@ package org.jenkinsci.plugins.github_branch_source; import com.cloudbees.jenkins.GitHubWebHook; -import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey; import com.cloudbees.plugins.credentials.CredentialsNameProvider; import com.cloudbees.plugins.credentials.common.StandardCredentials; import com.cloudbees.plugins.credentials.common.StandardListBoxModel; @@ -934,7 +933,7 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru SourceFactory sourceFactory = new SourceFactory(request); WitnessImpl witness = new WitnessImpl(listener); - boolean githubAppAuthentication = credentials instanceof GitHubAppCredential; + boolean githubAppAuthentication = credentials instanceof GitHubAppCredentials; if (!github.isAnonymous() && !githubAppAuthentication) { GHMyself myself; try { diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/config.jelly similarity index 100% rename from src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/config.jelly rename to src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/config.jelly diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-apiUri.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-apiUri.html similarity index 100% rename from src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-apiUri.html rename to src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-apiUri.html diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-appID.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-appID.html similarity index 100% rename from src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-appID.html rename to src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-appID.html diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-privateKey.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-privateKey.html similarity index 100% rename from src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredential/help-privateKey.html rename to src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-privateKey.html diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties index b609ef7f7..e75daef7a 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties @@ -67,4 +67,4 @@ ExcludeArchivedRepositoriesTrait.displayName=Exclude archived repositories GitHubSCMNavigator.general=General GitHubSCMNavigator.withinRepository=Within repository -GitHubAppCredential.displayName=GitHub app \ No newline at end of file +GitHubAppCredentials.displayName=GitHub app \ No newline at end of file From 4ad286e241f0f3f5702c98600f6fac7ebb363444 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 6 Feb 2020 09:39:07 +0000 Subject: [PATCH 41/49] Add JCasC compatibility test --- ...bAppCredentialsJCasCCompatibilityTest.java | 91 +++++++++++++++++++ ...hub-app-jcasc-minimal-expected-export.yaml | 4 + .../github-app-jcasc-minimal.yaml | 9 ++ 3 files changed, 104 insertions(+) create mode 100644 src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsJCasCCompatibilityTest.java create mode 100644 src/test/resources/org/jenkinsci/plugins/github_branch_source/github-app-jcasc-minimal-expected-export.yaml create mode 100644 src/test/resources/org/jenkinsci/plugins/github_branch_source/github-app-jcasc-minimal.yaml diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsJCasCCompatibilityTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsJCasCCompatibilityTest.java new file mode 100644 index 000000000..008f95e5e --- /dev/null +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentialsJCasCCompatibilityTest.java @@ -0,0 +1,91 @@ +package org.jenkinsci.plugins.github_branch_source; + +import com.cloudbees.plugins.credentials.Credentials; +import com.cloudbees.plugins.credentials.GlobalCredentialsConfiguration; +import com.cloudbees.plugins.credentials.SystemCredentialsProvider; +import com.cloudbees.plugins.credentials.casc.CredentialsRootConfigurator; +import com.cloudbees.plugins.credentials.domains.DomainCredentials; +import hudson.ExtensionList; +import io.jenkins.plugins.casc.ConfigurationContext; +import io.jenkins.plugins.casc.ConfiguratorRegistry; +import io.jenkins.plugins.casc.impl.configurators.GlobalConfigurationCategoryConfigurator; +import io.jenkins.plugins.casc.misc.ConfiguredWithCode; +import io.jenkins.plugins.casc.misc.EnvVarsRule; +import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule; +import io.jenkins.plugins.casc.model.CNode; +import io.jenkins.plugins.casc.model.Mapping; +import io.jenkins.plugins.casc.model.Sequence; +import java.util.List; +import java.util.Objects; +import jenkins.model.Jenkins; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.RuleChain; + +import static io.jenkins.plugins.casc.misc.Util.toStringFromYamlFile; +import static io.jenkins.plugins.casc.misc.Util.toYamlString; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; +import static org.jvnet.hudson.test.JenkinsMatchers.hasPlainText; + +public class GitHubAppCredentialsJCasCCompatibilityTest { + + @ConfiguredWithCode("github-app-jcasc-minimal.yaml") + public static JenkinsConfiguredWithCodeRule j = new JenkinsConfiguredWithCodeRule(); + + private static final String GITHUB_APP_KEY = "SomeString"; + + @ClassRule + public static RuleChain chain = RuleChain + .outerRule(new EnvVarsRule().set("GITHUB_APP_KEY", GITHUB_APP_KEY)) + .around(j); + + @Test + public void should_support_configuration_as_code() { + List domainCredentials = SystemCredentialsProvider.getInstance() + .getDomainCredentials(); + + assertThat(domainCredentials.size(), is(1)); + List credentials = domainCredentials.get(0).getCredentials(); + assertThat(credentials.size(), is(1)); + + Credentials credential = credentials.get(0); + assertThat(credential, instanceOf(GitHubAppCredentials.class)); + GitHubAppCredentials gitHubAppCredentials = (GitHubAppCredentials) credential; + + assertThat(gitHubAppCredentials.getAppID(), is("1111")); + assertThat(gitHubAppCredentials.getDescription(), is("GitHub app 1111")); + assertThat(gitHubAppCredentials.getId(), is("github-app")); + assertThat(gitHubAppCredentials.getPrivateKey(), hasPlainText(GITHUB_APP_KEY)); + } + + @Test + public void should_support_configuration_export() throws Exception { + Sequence credentials = getCredentials(); + CNode githubApp = credentials.get(0).asMapping().get("gitHubApp"); + + String exported = toYamlString(githubApp) + // replace secret with a constant value + .replaceAll("privateKey: .*", "privateKey: \"some-secret-value\""); + + String expected = toStringFromYamlFile(this, "github-app-jcasc-minimal-expected-export.yaml"); + + assertThat(exported, is(expected)); + } + + private Sequence getCredentials() throws Exception { + CredentialsRootConfigurator root = Jenkins.get() + .getExtensionList(CredentialsRootConfigurator.class).get(0); + + ConfiguratorRegistry registry = ConfiguratorRegistry.get(); + ConfigurationContext context = new ConfigurationContext(registry); + Mapping configNode = Objects + .requireNonNull(root.describe(root.getTargetComponent(context), context)).asMapping(); + Mapping domainCredentials = configNode + .get("system").asMapping().get("domainCredentials") + .asSequence() + .get(0).asMapping(); + return domainCredentials.get("credentials").asSequence(); + } +} diff --git a/src/test/resources/org/jenkinsci/plugins/github_branch_source/github-app-jcasc-minimal-expected-export.yaml b/src/test/resources/org/jenkinsci/plugins/github_branch_source/github-app-jcasc-minimal-expected-export.yaml new file mode 100644 index 000000000..ce7789c89 --- /dev/null +++ b/src/test/resources/org/jenkinsci/plugins/github_branch_source/github-app-jcasc-minimal-expected-export.yaml @@ -0,0 +1,4 @@ +appID: "1111" +description: "GitHub app 1111" +id: "github-app" +privateKey: "some-secret-value" diff --git a/src/test/resources/org/jenkinsci/plugins/github_branch_source/github-app-jcasc-minimal.yaml b/src/test/resources/org/jenkinsci/plugins/github_branch_source/github-app-jcasc-minimal.yaml new file mode 100644 index 000000000..6d3bc3ed9 --- /dev/null +++ b/src/test/resources/org/jenkinsci/plugins/github_branch_source/github-app-jcasc-minimal.yaml @@ -0,0 +1,9 @@ +credentials: + system: + domainCredentials: + - credentials: + - gitHubApp: + appID: "1111" + description: "GitHub app 1111" + id: "github-app" + privateKey: "${GITHUB_APP_KEY}" \ No newline at end of file From 91e4bf4cffe55ecdebaf19338ddf726d464c05be Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 6 Feb 2020 14:48:54 +0000 Subject: [PATCH 42/49] Update the docs --- docs/github-app.adoc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/github-app.adoc b/docs/github-app.adoc index e62480213..fea6ac0fb 100644 --- a/docs/github-app.adoc +++ b/docs/github-app.adoc @@ -74,6 +74,8 @@ openssl pkcs8 -topk8 -inform PEM -outform PEM -in key-in-your-downloads-folder.p == Adding the Jenkins credential +=== UI + - From the Jenkins main page click 'Credentials' - Pick your credential store, normally `(global)` - Click 'Add credentials' @@ -83,10 +85,27 @@ Fill out the form: - Kind: GitHub app - ID: i.e. github-app- - App ID: the github app ID, it can be found in the 'About' section of your GitHub app in the general tab. +- API endpoint (optional, only required for GitHub enterprise this will only show up if a GitHub enterprise server is configured). - Key: click add, paste the contents of the converted private key - Passphrase: do not fill this field, it will be ignored - Click OK +=== link:https://github.com/jenkinsci/configuration-as-code-plugin[Configuration as Code Plugin] + +[source,yaml] +---- +credentials: + system: + domainCredentials: + - credentials: + - gitHubApp: + appID: "1111" + description: "GitHub app" + id: "github-app" + # apiUri: https://my-custom-github-enterprise.com/api/v3 # optional only required for GitHub enterprise + privateKey: "${GITHUB_APP_KEY}" +---- + == Configuring the github organization folder See the link:https://docs.cloudbees.com/docs/admin-resources/latest/plugins/github-branch-source[main documentation] @@ -94,6 +113,8 @@ for how to create a GitHub folder. - Load the folders configuration page - Select the GitHub app credentials in the 'Credentials field drop down +- If you are using GitHub enterprise make sure the API url is set to your server, +(note you currently need to set the API url on both the credential and the job). After selecting the credential you should see: From ff0327a40b7847230856c6de6c32bb9611016d64 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 6 Feb 2020 16:31:43 +0000 Subject: [PATCH 43/49] Update docs/github-app.adoc Co-Authored-By: Olivier Jacques --- docs/github-app.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/github-app.adoc b/docs/github-app.adoc index fea6ac0fb..3ac990e9e 100644 --- a/docs/github-app.adoc +++ b/docs/github-app.adoc @@ -47,7 +47,7 @@ The only fields you need to fill out (currently) are: Permissions this plugin uses: - Commit statuses - Read and Write -- Contents: Read-only (to read the Jenkinsfile) +- Contents: Read-only (to read the `Jenkinsfile` and the repository content during `git fetch`). You may need "Read & write" to update the repository such as tagging releases - Metadata: Read-only - Pull requests: Read-only - Webhooks (optional) - If you want the plugin to manage webhooks for you, Read and Write From c961b07a22d4e957ab9f6f54d4a0a637e43622f6 Mon Sep 17 00:00:00 2001 From: Karl Shultz Date: Tue, 11 Feb 2020 21:24:12 -0500 Subject: [PATCH 44/49] Update .github/CONTRIBUTING.md Co-Authored-By: Alex Taylor --- .github/CONTRIBUTING.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5fc55f88e..1c31a9658 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -14,7 +14,7 @@ GitHub Branch Source is one of the most widely used plugins in the Jenkins plugi It is relied upon by hundreds of thousands of people worldwide. Because of this huge install base, caution must be exercised when making changes. Code changes are reviewed with a high level of scrutiny, out of necessity. This level of thoroughness should not be interpreted -as a personal attack. (And, of course, if it is a personal attack, that's why we have the +as a personal attack. (And, of course, someone feels it is a personal attack, that's why we have the [Code of Conduct](https://jenkins.io/project/conduct/) in place). ## How to submit your contribution @@ -103,4 +103,3 @@ The process by which pull requests get merged to master is fairly simple, and is in the [guide for releasing a plugin](https://jenkins.io/doc/developer/publishing/releasing/). In short, once changes are merged to master, a release can be generated. Final decisions on merging and releasing fall to the plugin's maintainer. - From e29a13e5b5d8533d7cc09ee4f97c63bed2a5841c Mon Sep 17 00:00:00 2001 From: Karl Shultz Date: Tue, 11 Feb 2020 21:26:51 -0500 Subject: [PATCH 45/49] Add an if --- .github/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 1c31a9658..5075284e6 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -14,7 +14,7 @@ GitHub Branch Source is one of the most widely used plugins in the Jenkins plugi It is relied upon by hundreds of thousands of people worldwide. Because of this huge install base, caution must be exercised when making changes. Code changes are reviewed with a high level of scrutiny, out of necessity. This level of thoroughness should not be interpreted -as a personal attack. (And, of course, someone feels it is a personal attack, that's why we have the +as a personal attack. (And, of course, if someone feels it is a personal attack, that's why we have the [Code of Conduct](https://jenkins.io/project/conduct/) in place). ## How to submit your contribution From 55e7f95c1946a14ad2bd16248f1fd964a25cf3b6 Mon Sep 17 00:00:00 2001 From: Fred G Date: Thu, 13 Feb 2020 12:20:31 +0100 Subject: [PATCH 46/49] [JENKINS-59485] Trust level "Contributors" is ambiguous, should be called "Collaborators" instead Change only display name in drop down and in help text --- .../ForkPullRequestDiscoveryTrait/help-trust.html | 4 ++-- .../plugins/github_branch_source/Messages.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait/help-trust.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait/help-trust.html index be45999bf..7e9a0404c 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait/help-trust.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/ForkPullRequestDiscoveryTrait/help-trust.html @@ -17,13 +17,13 @@ trusted file (e.g. Jenkinsfile) the contents of that file will be retrieved from the target branch on the origin repository and not from the pull request branch on the fork repository. -
Contributors
+
Collaborators
Pull requests from collaborators to the origin repository will be treated as trusted, all other pull requests from fork repositories will be treated as untrusted. Note that if credentials used by Jenkins for scanning the repository does not have permission to - query the list of contributors to the origin repository then only the origin account will be treated + query the list of collaborators to the origin repository then only the origin account will be treated as trusted - i.e. this will fall back to Nobody. NOTE: all collaborators are trusted, even if they are only members of a team with read permission.
diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties index 72b7e2bac..0021d9240 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties @@ -1,7 +1,7 @@ BranchSCMHead.Pronoun=Branch GitHubTagSCMHead.Pronoun=Tag -ForkPullRequestDiscoveryTrait.contributorsDisplayName=Contributors +ForkPullRequestDiscoveryTrait.contributorsDisplayName=Collaborators ForkPullRequestDiscoveryTrait.permissionsDisplayName=From users with Admin or Write permission ForkPullRequestDiscoveryTrait.displayName=Discover pull requests from forks ForkPullRequestDiscoveryTrait.everyoneDisplayName=Everyone From d33000aec5cf9758fba59ab8bcb3829894f85eea Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Mon, 17 Feb 2020 20:17:33 +0000 Subject: [PATCH 47/49] Apply suggestions from code review Co-Authored-By: Oleg Nenashev --- README.md | 2 +- .../github_branch_source/GitHubAppCredentials/config.jelly | 2 +- .../github_branch_source/GitHubAppCredentials/help-apiUri.html | 2 +- .../github_branch_source/GitHubAppCredentials/help-appID.html | 2 +- .../GitHubAppCredentials/help-privateKey.html | 2 +- .../jenkinsci/plugins/github_branch_source/Messages.properties | 2 +- .../jenkinsci/plugins/github_branch_source/JwtHelperTest.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 96c3259d7..6c7b3957b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ GitHub users or organizations. Complete documentation is ### Guides -* [GitHub app authentication](docs/github-app.adoc) +* [GitHub App authentication](docs/github-app.adoc) * [Extension points provided by this plugin](docs/implementation.adoc) ## Extension plugins diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/config.jelly b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/config.jelly index 7544d9d58..5efc33569 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/config.jelly @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-apiUri.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-apiUri.html index 72fce8569..d2a930aa1 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-apiUri.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-apiUri.html @@ -1,3 +1,3 @@

GitHub API endpoint such as https://github.example.com/api/v3/. -

\ No newline at end of file +

diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-appID.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-appID.html index d85fa8314..ca33b4078 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-appID.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-appID.html @@ -1,3 +1,3 @@

GitHub app ID, can be found on the App's settings, on the General page in the About section -

\ No newline at end of file +

diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-privateKey.html b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-privateKey.html index 00374b9d8..995e6f0fe 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-privateKey.html +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/GitHubAppCredentials/help-privateKey.html @@ -3,4 +3,4 @@

You can convert it with openssl pkcs8 -topk8 -inform PEM -outform PEM -in current-key.pem -out new-key.pem -nocrypt -

\ No newline at end of file +

diff --git a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties index e75daef7a..25c888f76 100644 --- a/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties +++ b/src/main/resources/org/jenkinsci/plugins/github_branch_source/Messages.properties @@ -67,4 +67,4 @@ ExcludeArchivedRepositoriesTrait.displayName=Exclude archived repositories GitHubSCMNavigator.general=General GitHubSCMNavigator.withinRepository=Within repository -GitHubAppCredentials.displayName=GitHub app \ No newline at end of file +GitHubAppCredentials.displayName=GitHub App diff --git a/src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java b/src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java index 139ec5327..4fd37d0e8 100644 --- a/src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java +++ b/src/test/java/org/jenkinsci/plugins/github_branch_source/JwtHelperTest.java @@ -125,4 +125,4 @@ private static PublicKey getPublicKeyFromString(final String key) throws General return kf.generatePublic(keySpecPKCS8); } -} \ No newline at end of file +} From d1423c4ffa59a877346cd918290046b159c81bf8 Mon Sep 17 00:00:00 2001 From: Karl Shultz Date: Mon, 24 Feb 2020 14:53:24 -0500 Subject: [PATCH 48/49] Add docs and users section. Minor reword. --- .github/PULL_REQUEST_TEMPLATE.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 5c6fc69e7..ef8778d3b 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -4,7 +4,7 @@ A brief summary describing the changes in this pull request. See [JENKINS-XXXXX](https://issues.jenkins-ci.org/browse/JENKINS-XXXXX) for further information. # Submitter checklist - [ ] Link to JIRA ticket in description, if appropriate. @@ -17,3 +17,8 @@ In the lists below, replace the empty checkboxes [ ] with checks by replacing th - [ ] Reviewed the code - [ ] Verified that the appropriate tests have been written or valid explanation given +# Documentation changes +- [ ] Link to jenkins.io PR, or an explanation for why no doc changes are needed + +# Users/aliases to notify + From e40c0b61c444c172270faa50756a8c1009dcd242 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Tue, 17 Mar 2020 11:13:06 -0700 Subject: [PATCH 49/49] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9200950a..a7d349043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +For version 2.6.0 and beyond, see the [GitHub releases](https://github.com/jenkinsci/github-branch-source-plugin/releases) list. + ## Version 2.5.8 Release date: 2019-09-27