Merge branch 'stable-3.5'
* stable-3.5:
Honour `userNameCaseInsensitive` config
Set project version to v3.5.0.1
Change-Id: I1831ab6e15931052745a621d51c87e97f7baad61
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..f706539 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
@@ -26,6 +26,7 @@
import com.google.gerrit.server.account.AccountImporter;
import com.google.gerrit.server.account.externalids.ExternalId;
import com.google.gerrit.server.account.externalids.ExternalIds;
+import com.google.gerrit.server.config.AuthConfig;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.server.project.ProjectState;
@@ -79,6 +80,7 @@
private final String repoName;
private final int prId;
private final GitRepositoryManager repoMgr;
+ private final AuthConfig authConfig;
private final int jobIndex;
private final ExternalIds externalIds;
private PullRequestCreateChange createChange;
@@ -96,10 +98,12 @@
GitHubRepository.Factory gitHubRepoFactory,
ScopedProvider<GitHubLogin> ghLoginProvider,
ExternalIds externalIds,
+ AuthConfig authConfig,
@Assisted("index") int jobIndex,
@Assisted("organisation") String organisation,
@Assisted("name") String repoName,
@Assisted int pullRequestId) {
+ this.authConfig = authConfig;
this.jobIndex = jobIndex;
this.repoMgr = repoMgr;
this.ghLogin = ghLoginProvider.get();
@@ -217,8 +221,9 @@
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, authConfig.isUserNameCaseInsensitive()));
+ } 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..23edcbc 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,7 +32,9 @@
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.config.AuthConfig;
import com.google.gerrit.server.restapi.account.AddSshKey;
import com.google.gerrit.server.restapi.account.GetSshKeys;
import com.google.gerrit.server.restapi.account.PutName;
@@ -68,6 +70,9 @@
private final PutName putName;
private final Provider<AccountsUpdate> accountsUpdateProvider;
private final ExternalIds externalIds;
+ private final ExternalIdFactory externalIdFactory;
+ private final AuthRequest.Factory authRequestFactory;
+ private final AuthConfig authConfig;
@Inject
public AccountController(
@@ -78,7 +83,10 @@
final PutPreferred putPreferred,
final PutName putName,
@ServerInitiated final Provider<AccountsUpdate> accountsUpdateProvider,
- final ExternalIds externalIds) {
+ final ExternalIds externalIds,
+ final ExternalIdFactory externalIdFactory,
+ final AuthRequest.Factory authRequestFactory,
+ final AuthConfig authConfig) {
this.restAddSshKey = restAddSshKey;
this.restGetSshKeys = restGetSshKeys;
this.accountManager = accountManager;
@@ -87,6 +95,9 @@
this.putName = putName;
this.accountsUpdateProvider = accountsUpdateProvider;
this.externalIds = externalIds;
+ this.externalIdFactory = externalIdFactory;
+ this.authRequestFactory = authRequestFactory;
+ this.authConfig = authConfig;
}
@Override
@@ -120,7 +131,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 +139,12 @@
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, authConfig.isUserNameCaseInsensitive());
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 +160,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>