Merge branch 'stable-3.8' * stable-3.8: Add support for virtual host based wizard flow Change-Id: I260557af0d3bd4ee35d3373ae010f6026f72ed07
diff --git a/README.md b/README.md index 5a95019..569c7b2 100644 --- a/README.md +++ b/README.md
@@ -136,9 +136,10 @@ * GitHub Integration * GitHub URL: [https://github.com]: <confirm> -* Use GitHub for Gerrit login? [Y/n] Y +* GitHub API URL: [https://api.github.com]: <confirm> * ClientId []: <provided client id from previous step> * ClientSecret []: <provided client secret from previous step> +* Gerrit OAuth implementation [http/?]: <http or oauth> ### Receiving Pull Request events to automatically import @@ -195,4 +196,4 @@ refs/for/foo, refs/meta/bar ``` -More information on Gerrit magic refs can be found [here](https://gerrit-review.googlesource.com/Documentation/intro-user.html#upload-change) \ No newline at end of file +More information on Gerrit magic refs can be found [here](https://gerrit-review.googlesource.com/Documentation/intro-user.html#upload-change)
diff --git a/github-oauth/pom.xml b/github-oauth/pom.xml index 75b9c09..4372d9c 100644 --- a/github-oauth/pom.xml +++ b/github-oauth/pom.xml
@@ -89,12 +89,12 @@ <dependency> <groupId>org.kohsuke</groupId> <artifactId>github-api</artifactId> - <version>1.116</version> + <version>1.315</version> </dependency> <dependency> <groupId>com.infradna.tool</groupId> <artifactId>bridge-method-injector</artifactId> - <version>1.18</version> + <version>1.23</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId>
diff --git a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java index 6db2338..1aed6cf 100644 --- a/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java +++ b/github-oauth/src/main/java/com/googlesource/gerrit/plugins/github/oauth/GitHubLogin.java
@@ -38,7 +38,8 @@ import org.kohsuke.github.GHMyself; import org.kohsuke.github.GitHub; import org.kohsuke.github.GitHubBuilder; -import org.kohsuke.github.HttpConnector; +import org.kohsuke.github.connector.GitHubConnector; +import org.kohsuke.github.internal.GitHubConnectorHttpConnectorAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,7 +64,7 @@ private SortedSet<Scope> loginScopes; private final GitHubOAuthConfig config; - private final HttpConnector httpConnector; + private final GitHubConnector gitHubConnector; public GHMyself getMyself() throws IOException { if (isLoggedIn()) { @@ -82,7 +83,7 @@ @Inject public GitHubLogin(GitHubOAuthConfig config, GitHubHttpConnector httpConnector) { this.config = config; - this.httpConnector = httpConnector; + this.gitHubConnector = GitHubConnectorHttpConnectorAdapter.adapt(httpConnector); } public boolean isLoggedIn() { @@ -141,7 +142,7 @@ return new GitHubBuilder() .withEndpoint(config.gitHubApiUrl) .withOAuthToken(token.accessToken) - .withConnector(httpConnector) + .withConnector(gitHubConnector) .build(); }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java index f26188d..d359526 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/BatchImporter.java
@@ -44,7 +44,7 @@ } public synchronized void schedule(int idx, GitJob pullRequestImportJob) { - jobs.put(new Integer(idx), pullRequestImportJob); + jobs.put(Integer.valueOf(idx), pullRequestImportJob); executor.exec(pullRequestImportJob); } }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitCloneStep.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitCloneStep.java index 0e0e72d..25d953b 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitCloneStep.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitCloneStep.java
@@ -44,11 +44,8 @@ private static final Logger LOG = LoggerFactory.getLogger(GitImporter.class); private final GitHubConfig config; - private final File gitDir; private final GerritApi gerritApi; private final OneOffRequestContext context; - private final String organisation; - private final String repository; private final File destinationDirectory; private final DynamicSet<ProjectDeletedListener> deletedListeners; private final ProjectCache projectCache; @@ -75,14 +72,11 @@ super(config.gitHubUrl, organisation, repository, gitHubRepoFactory); LOG.debug("GitHub Clone " + organisation + "/" + repository); this.config = config; - this.gitDir = config.gitDir.toFile(); this.gerritApi = gerritApi; this.context = context; - this.organisation = organisation; - this.repository = repository; this.projectName = organisation + "/" + repository; - this.destinationDirectory = prepareTargetGitDirectory(gitDir, this.projectName); + this.destinationDirectory = prepareTargetGitDirectory(config.gitDir.toFile(), this.projectName); this.deletedListeners = deletedListeners; this.projectCache = projectCache; this.repoManager = repoManager; @@ -128,10 +122,6 @@ } } - private boolean isNotEmpty(File destDirectory) { - return destDirectory.listFiles().length > 0; - } - @Override public boolean rollback() { File gitDirectory = destinationDirectory;
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/MagicRefFoundException.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/MagicRefFoundException.java index 263ee9d..42b7e36 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/MagicRefFoundException.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/MagicRefFoundException.java
@@ -15,6 +15,8 @@ public class MagicRefFoundException extends GitException { + private static final long serialVersionUID = 1L; + public MagicRefFoundException(String message) { super(message); }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ProtectedBranchFoundException.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ProtectedBranchFoundException.java index 221152f..c156150 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ProtectedBranchFoundException.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/ProtectedBranchFoundException.java
@@ -16,6 +16,8 @@ public class ProtectedBranchFoundException extends Exception { + private static final long serialVersionUID = 1L; + public ProtectedBranchFoundException(String msg) { super(msg); }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java index 3d0ec26..f2a7f06 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestCreateChange.java
@@ -39,7 +39,6 @@ import com.google.gerrit.server.query.change.InternalChangeQuery; import com.google.gerrit.server.update.BatchUpdate; import com.google.gerrit.server.update.UpdateException; -import com.google.gerrit.server.util.time.TimeUtil; import com.google.inject.Inject; import com.google.inject.Provider; import java.io.IOException; @@ -101,9 +100,7 @@ RestApiException { try (BatchUpdate bu = updateFactory.create( - project.getNameKey(), - userFactory.create(pullRequestOwner), - Instant.now())) { + project.getNameKey(), userFactory.create(pullRequestOwner), Instant.now())) { return internalAddCommitToChange( bu,
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java index 52d7b34..da16dc2 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/PullRequestImportJob.java
@@ -191,7 +191,7 @@ pullRequestOwner, revCommit, getChangeMessage(pr), - String.format(TOPIC_FORMAT, new Integer(pr.getNumber()))); + String.format(TOPIC_FORMAT, Integer.valueOf(pr.getNumber()))); if (changeId != null) { prChanges.add(changeId); }
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java index 540b98a..361ccc2 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/notification/PullRequestHandler.java
@@ -46,7 +46,7 @@ String action = payload.getAction(); if (action.equals("opened") || action.equals("synchronize")) { GHRepository repository = payload.getRepository(); - Integer prNumber = new Integer(payload.getNumber()); + Integer prNumber = Integer.valueOf(payload.getNumber()); PullRequestImporter prImporter = prImportProvider.get(); String organization = repository.getOwnerName(); String name = repository.getName();
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/GitHubDestinations.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/GitHubDestinations.java index af644fe..810632a 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/GitHubDestinations.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/replication/GitHubDestinations.java
@@ -20,7 +20,6 @@ import com.google.gerrit.server.account.GroupBackend; import com.google.gerrit.server.config.SitePaths; import com.google.inject.Inject; -import com.google.inject.Injector; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; @@ -52,24 +51,20 @@ return null; } - private final Injector injector; private final List<Destination> configs; private final RemoteSiteUser.Factory replicationUserFactory; private final PluginUser pluginUser; private final GroupBackend groupBackend; - boolean replicateAllOnPluginStart; private final List<String> organisations; @Inject GitHubDestinations( - final Injector i, final SitePaths site, final RemoteSiteUser.Factory ruf, final GroupBackend gb, final PluginUser pu) throws ConfigInvalidException, IOException { - injector = i; pluginUser = pu; replicationUserFactory = ruf; groupBackend = gb;
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java index fc578af..0bb7e3e 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/AccountController.java
@@ -25,7 +25,6 @@ import com.google.gerrit.extensions.restapi.RawInput; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.ServerInitiated; -import com.google.gerrit.server.account.AccountCache; import com.google.gerrit.server.account.AccountManager; import com.google.gerrit.server.account.AccountResource; import com.google.gerrit.server.account.AccountsUpdate; @@ -65,7 +64,6 @@ private final AddSshKey restAddSshKey; private final GetSshKeys restGetSshKeys; private final AccountManager accountManager; - private final AccountCache accountCache; private final PutPreferred putPreferred; private final PutName putName; private final Provider<AccountsUpdate> accountsUpdateProvider; @@ -79,7 +77,6 @@ final AddSshKey restAddSshKey, final GetSshKeys restGetSshKeys, final AccountManager accountManager, - final AccountCache accountCache, final PutPreferred putPreferred, final PutName putName, @ServerInitiated final Provider<AccountsUpdate> accountsUpdateProvider, @@ -90,7 +87,6 @@ this.restAddSshKey = restAddSshKey; this.restGetSshKeys = restGetSshKeys; this.accountManager = accountManager; - this.accountCache = accountCache; this.putPreferred = putPreferred; this.putName = putName; this.accountsUpdateProvider = accountsUpdateProvider;
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java index e47f161..b7fc801 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/PullRequestListController.java
@@ -101,7 +101,7 @@ JsonArray prArray = new JsonArray(); for (GHPullRequest pr : repoEntry.getValue()) { JsonObject prObj = new JsonObject(); - prObj.add("id", new JsonPrimitive(new Integer(pr.getNumber()))); + prObj.add("id", new JsonPrimitive(Integer.valueOf(pr.getNumber()))); prObj.add("title", new JsonPrimitive(Strings.nullToEmpty(pr.getTitle()))); prObj.add("body", new JsonPrimitive(Strings.nullToEmpty(pr.getBody()))); prObj.add( @@ -137,7 +137,7 @@ if (githubRepo.isPresent()) { numPullRequests = collectPullRequestsFromGitHubRepository( - numPullRequests, allPullRequests, gitRepo, ghRepoName, githubRepo); + numPullRequests, allPullRequests, gitRepo, ghRepoName, githubRepo.get()); } } } @@ -149,13 +149,14 @@ Map<String, List<GHPullRequest>> allPullRequests, Repository gitRepo, String ghRepoName, - Optional<GHRepository> githubRepo) + GHRepository githubRepo) throws IncorrectObjectTypeException, IOException { List<GHPullRequest> repoPullRequests = Lists.newArrayList(); int count = numPullRequests; if (count < config.pullRequestListLimit) { - for (GHPullRequest ghPullRequest : githubRepo.get().listPullRequests(GHIssueState.OPEN)) { + for (GHPullRequest ghPullRequest : + githubRepo.queryPullRequests().state(GHIssueState.OPEN).list()) { if (isAnyCommitOfPullRequestToBeImported(gitRepo, ghPullRequest)) { repoPullRequests.add(ghPullRequest);
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java index 2cf6170..01a3d25 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/wizard/RepositoriesListController.java
@@ -72,7 +72,7 @@ repository.add("organisation", new JsonPrimitive(organisation)); repository.add( "description", new JsonPrimitive(Strings.nullToEmpty(ghRepository.getDescription()))); - repository.add("private", new JsonPrimitive(new Boolean(ghRepository.isPrivate()))); + repository.add("private", new JsonPrimitive(Boolean.valueOf(ghRepository.isPrivate()))); jsonRepos.add(repository); numRepos++; }