Set project version to v3.5.0.1 Also adapt to Gerrit v3.5.0, including the conversion to case-insensitive as GitHub accounts are. Change-Id: Ie20512ad97004cdfccd5a459da185827862d5863
diff --git a/github-oauth/pom.xml b/github-oauth/pom.xml index 3d55bc8..0b7a9b5 100644 --- a/github-oauth/pom.xml +++ b/github-oauth/pom.xml
@@ -21,7 +21,7 @@ <parent> <groupId>com.googlesource.gerrit.plugins.github</groupId> <artifactId>github-parent</artifactId> - <version>3.5.0-SNAPSHOT</version> + <version>3.5.0.1</version> </parent> <artifactId>github-oauth</artifactId> <name>Gerrit Code Review - GitHub OAuth login</name>
diff --git a/github-plugin/pom.xml b/github-plugin/pom.xml index d034f0b..fed554e 100644 --- a/github-plugin/pom.xml +++ b/github-plugin/pom.xml
@@ -20,7 +20,7 @@ <parent> <artifactId>github-parent</artifactId> <groupId>com.googlesource.gerrit.plugins.github</groupId> - <version>3.5.0-SNAPSHOT</version> + <version>3.5.0.1</version> </parent> <artifactId>github-plugin</artifactId>
diff --git a/github-plugin/src/main/java/com/google/gerrit/server/account/AccountImporter.java b/github-plugin/src/main/java/com/google/gerrit/server/account/AccountImporter.java index 19ed82f..e826880 100644 --- a/github-plugin/src/main/java/com/google/gerrit/server/account/AccountImporter.java +++ b/github-plugin/src/main/java/com/google/gerrit/server/account/AccountImporter.java
@@ -17,6 +17,7 @@ import com.google.gerrit.entities.Account; import com.google.gerrit.server.ServerInitiated; import com.google.gerrit.server.account.externalids.ExternalId; +import com.google.gerrit.server.account.externalids.ExternalIdFactory; import com.google.gerrit.server.notedb.Sequences; import com.google.inject.Inject; import com.google.inject.Provider; @@ -28,21 +29,25 @@ public class AccountImporter { private final Sequences sequences; private final Provider<AccountsUpdate> accountsUpdateProvider; + private final ExternalIdFactory externalIdFactory; @Inject public AccountImporter( - Sequences sequences, @ServerInitiated Provider<AccountsUpdate> accountsUpdateProvider) { + Sequences sequences, + @ServerInitiated Provider<AccountsUpdate> accountsUpdateProvider, + ExternalIdFactory externalIdFactory) { this.sequences = sequences; this.accountsUpdateProvider = accountsUpdateProvider; + this.externalIdFactory = externalIdFactory; } public Account.Id importAccount(String login, String name, String email) throws IOException, ConfigInvalidException { Account.Id id = Account.id(sequences.nextAccountId()); List<ExternalId> extIds = new ArrayList<>(); - extIds.add(ExternalId.createEmail(id, email)); - extIds.add(ExternalId.create(ExternalId.SCHEME_GERRIT, login, id)); - extIds.add(ExternalId.create(ExternalId.SCHEME_USERNAME, login, id)); + extIds.add(externalIdFactory.createEmail(id, email)); + extIds.add(externalIdFactory.create(ExternalId.SCHEME_GERRIT, login, id)); + extIds.add(externalIdFactory.create(ExternalId.SCHEME_USERNAME, login, id)); AccountState accountUpdate = accountsUpdateProvider .get()
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 cb71e78..9395056 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
@@ -217,8 +217,8 @@ private Optional<ExternalId> externalIdByScheme(String scheme, String id) { try { - return externalIds.get(ExternalId.Key.create(scheme, id)); - } catch (IOException | ConfigInvalidException e) { + return externalIds.get(ExternalId.Key.create(scheme, id, true)); + } catch (IOException e) { LOG.error("Unable to get external id for " + scheme + ":" + id, e); return Optional.empty(); }
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 e2b8041..59604ef 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
@@ -32,6 +32,7 @@ import com.google.gerrit.server.account.AuthRequest; import com.google.gerrit.server.account.AuthResult; import com.google.gerrit.server.account.externalids.ExternalId; +import com.google.gerrit.server.account.externalids.ExternalIdFactory; import com.google.gerrit.server.account.externalids.ExternalIds; import com.google.gerrit.server.restapi.account.AddSshKey; import com.google.gerrit.server.restapi.account.GetSshKeys; @@ -68,6 +69,8 @@ private final PutName putName; private final Provider<AccountsUpdate> accountsUpdateProvider; private final ExternalIds externalIds; + private final ExternalIdFactory externalIdFactory; + private final AuthRequest.Factory authRequestFactory; @Inject public AccountController( @@ -78,7 +81,9 @@ final PutPreferred putPreferred, final PutName putName, @ServerInitiated final Provider<AccountsUpdate> accountsUpdateProvider, - final ExternalIds externalIds) { + final ExternalIds externalIds, + final ExternalIdFactory externalIdFactory, + final AuthRequest.Factory authRequestFactory) { this.restAddSshKey = restAddSshKey; this.restGetSshKeys = restGetSshKeys; this.accountManager = accountManager; @@ -87,6 +92,8 @@ this.putName = putName; this.accountsUpdateProvider = accountsUpdateProvider; this.externalIds = externalIds; + this.externalIdFactory = externalIdFactory; + this.authRequestFactory = authRequestFactory; } @Override @@ -120,7 +127,7 @@ String username = req.getParameter("username"); try { Id accountId = user.getAccountId(); - AuthResult result = accountManager.link(accountId, AuthRequest.forEmail(email)); + AuthResult result = accountManager.link(accountId, authRequestFactory.createForEmail(email)); log.debug("Account {} linked to email {}: result = {}", accountId, email, result); putPreferred.apply(new AccountResource.Email(user, email), null); @@ -128,11 +135,11 @@ nameInput.name = fullName; putName.apply(user, nameInput); - ExternalId.Key key = ExternalId.Key.create(SCHEME_USERNAME, username); + ExternalId.Key key = ExternalId.Key.create(SCHEME_USERNAME, username, true); Optional<ExternalId> other; try { other = externalIds.get(key); - } catch (IOException | ConfigInvalidException e) { + } catch (IOException e) { throw new IllegalArgumentException( "Internal error while fetching username='" + username + "'"); } @@ -148,7 +155,7 @@ .update( "Set Username from GitHub", accountId, - u -> u.addExternalId(ExternalId.create(key, accountId, null, null))); + u -> u.addExternalId(externalIdFactory.create(key, accountId, null, null))); } catch (Exception e) { throw new IllegalArgumentException( "Internal error while trying to set username='" + username + "'");
diff --git a/pom.xml b/pom.xml index 950560d..72d4915 100644 --- a/pom.xml +++ b/pom.xml
@@ -18,7 +18,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>com.googlesource.gerrit.plugins.github</groupId> <artifactId>github-parent</artifactId> - <version>3.5.0-SNAPSHOT</version> + <version>3.5.0.1</version> <name>Gerrit Code Review - GitHub integration</name> <url>http://www.gerritforge.com</url> <packaging>pom</packaging>