Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexei.trebounskikh2018-11-28 20:28:55 -0500
committeralexei.trebounskikh2018-11-29 02:50:34 -0500
commite5d08a7ecd02324d592909e57f767277b9b04c3e (patch)
treeb0534d5f77b4762665dfb31bc0070457d70bab64
parent0eb391edbd6508eea720d493fd14bc031b2da8f3 (diff)
downloadorg.eclipse.mylyn.reviews-e5d08a7ecd02324d592909e57f767277b9b04c3e.tar.gz
org.eclipse.mylyn.reviews-e5d08a7ecd02324d592909e57f767277b9b04c3e.tar.xz
org.eclipse.mylyn.reviews-e5d08a7ecd02324d592909e57f767277b9b04c3e.zip
Bug 485981: (Gerrit2.12.4Support) - support Gerrit >=2.12.4
* fixed ability to clone gerrit repos Change-Id: If308a76bc83c8899e48858fc8a2449774584015d Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=537208 Signed-off-by: alexei.trebounskikh <alexei.trebounskikh@tasktop.com>
-rw-r--r--org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtilTest.java9
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtil.java36
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java12
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient212.java68
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/DownloadSchemeX.java35
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/GerritConfigX.java12
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/SchemeInfo.java56
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/DownloadInfo.java28
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/DownloadSchemeInfo.java52
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/GerritInfo.java28
-rw-r--r--org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/ServerInfo.java32
-rw-r--r--org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java13
-rw-r--r--org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/support/GerritFixture.java17
13 files changed, 387 insertions, 11 deletions
diff --git a/org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtilTest.java b/org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtilTest.java
index a9174056..ed8dbe54 100644
--- a/org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtilTest.java
+++ b/org.eclipse.mylyn.gerrit.core.tests/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtilTest.java
@@ -15,6 +15,9 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
+import com.google.gerrit.reviewdb.Project;
+import com.google.gerrit.reviewdb.Project.NameKey;
+
public class GerritUtilTest {
@Test
@@ -28,4 +31,10 @@ public class GerritUtilTest {
GerritUtil.toChangeId("abc~I95aa5d1d28009ecc6a59b1bf33a2866d186e5c62"));
}
+ @Test
+ public void forProject() {
+ Project project = new Project(new NameKey("some_name"));
+ assertEquals("http://jdoe@gerrithost:8080/" + project.getName(),
+ GerritUtil.forProject("http://jdoe@gerrithost:8080/${project}", project));
+ }
}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtil.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtil.java
index 296de855..828b5228 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtil.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/GerritUtil.java
@@ -20,7 +20,9 @@ import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.runtime.Assert;
import org.eclipse.mylyn.internal.gerrit.core.client.GerritConfiguration;
+import org.eclipse.mylyn.internal.gerrit.core.client.compat.DownloadSchemeX;
import org.eclipse.mylyn.internal.gerrit.core.client.compat.ProjectDetailX;
+import org.eclipse.mylyn.internal.gerrit.core.client.compat.SchemeInfo;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.osgi.util.NLS;
@@ -89,6 +91,11 @@ public class GerritUtil {
public static String getSshCloneUri(TaskRepository repository, GerritConfiguration config, Project project)
throws URISyntaxException {
+
+ if (supportsDownloadScheme(config, DownloadSchemeX.SSH)) {
+ return getSchemeUri(config, DownloadSchemeX.SSH, project);
+ }
+
Set<DownloadScheme> supportedDownloadSchemes = config.getGerritConfig().getDownloadSchemes();
if (supportedDownloadSchemes.contains(DownloadScheme.SSH)
|| supportedDownloadSchemes.contains(DownloadScheme.DEFAULT_DOWNLOADS)) {
@@ -120,6 +127,10 @@ public class GerritUtil {
}
public static String getHttpCloneUri(TaskRepository repository, GerritConfiguration config, Project project) {
+ if (supportsDownloadScheme(config, DownloadSchemeX.HTTP)) {
+ return getSchemeUri(config, DownloadSchemeX.HTTP, project);
+ }
+
Set<DownloadScheme> supportedDownloadSchemes = config.getGerritConfig().getDownloadSchemes();
if (supportedDownloadSchemes.contains(DownloadScheme.HTTP)
|| supportedDownloadSchemes.contains(DownloadScheme.DEFAULT_DOWNLOADS)) {
@@ -153,6 +164,10 @@ public class GerritUtil {
}
public static String getAnonHttpCloneUri(TaskRepository repository, GerritConfiguration config, Project project) {
+ if (supportsDownloadScheme(config, DownloadSchemeX.ANON_HTTP)) {
+ return getSchemeUri(config, DownloadSchemeX.ANON_HTTP, project);
+ }
+
Set<DownloadScheme> supportedDownloadSchemes = config.getGerritConfig().getDownloadSchemes();
if (supportedDownloadSchemes.contains(DownloadScheme.ANON_HTTP)
|| supportedDownloadSchemes.contains(DownloadScheme.DEFAULT_DOWNLOADS)) {
@@ -176,10 +191,14 @@ public class GerritUtil {
}
public static String getAnonGitCloneUri(TaskRepository repository, GerritConfiguration config, Project project) {
+ if (supportsDownloadScheme(config, DownloadSchemeX.GIT)) {
+ return getSchemeUri(config, DownloadSchemeX.GIT, project);
+ }
+
Set<DownloadScheme> supportedDownloadSchemes = config.getGerritConfig().getDownloadSchemes();
String gitAddress = config.getGerritConfig().getGitDaemonUrl();
- if (gitAddress != null
- && (supportedDownloadSchemes.contains(DownloadScheme.ANON_GIT) || supportedDownloadSchemes.contains(DownloadScheme.DEFAULT_DOWNLOADS))) {
+ if (gitAddress != null && (supportedDownloadSchemes.contains(DownloadScheme.ANON_GIT)
+ || supportedDownloadSchemes.contains(DownloadScheme.DEFAULT_DOWNLOADS))) {
final StringBuilder sb = new StringBuilder();
sb.append(gitAddress);
if (!gitAddress.endsWith("/")) { //$NON-NLS-1$
@@ -213,4 +232,17 @@ public class GerritUtil {
return id;
}
+ private static boolean supportsDownloadScheme(GerritConfiguration config, DownloadSchemeX scheme) {
+ return config.getGerritConfig().getSchemes() != null
+ && config.getGerritConfig().getSchemes().containsKey(scheme);
+ }
+
+ private static String getSchemeUri(GerritConfiguration config, DownloadSchemeX scheme, Project project) {
+ SchemeInfo info = config.getGerritConfig().getSchemes().get(scheme);
+ return info != null ? forProject(info.getUrl(), project) : null;
+ }
+
+ public static String forProject(String url, Project project) {
+ return url.replaceAll("\\$\\{project\\}", project.getName()); //$NON-NLS-1$
+ }
}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java
index 84311fe0..cfb3c17f 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient.java
@@ -187,14 +187,14 @@ public abstract class GerritClient extends ReviewsClient {
GerritConfiguration config, GerritAuthenticationState authState, String xsrfKey,
GerritClientStateListener stateListener) {
Version version = Version.emptyVersion;
- GerritClient versionDiscoveryClient = new GerritClient29(repository, version);
+ GerritClient versionDiscoveryClient = new GerritClient212(repository, version);
versionDiscoveryClient.initialize(location, config, authState, xsrfKey, stateListener);
try {
version = versionDiscoveryClient.getVersion(new NullProgressMonitor());
} catch (GerritException e) {
//Ignore, we'll just use the base client.
}
- GerritClient client = new GerritClient29(repository, version);
+ GerritClient client = new GerritClient212(repository, version);
client.initialize(location, config, authState, xsrfKey, stateListener);
return client;
}
@@ -226,7 +226,7 @@ public abstract class GerritClient extends ReviewsClient {
}
this.serviceByClass = new HashMap<Class<? extends RemoteJsonService>, RemoteJsonService>();
this.config = config;
- this.restClient = new GerritRestClient(this.client);
+ this.restClient = new GerritRestClient(client);
}
public GerritSystemInfo getInfo(IProgressMonitor monitor) throws GerritException {
@@ -298,7 +298,7 @@ public abstract class GerritClient extends ReviewsClient {
if (gerritConfig == null) {
if (GerritVersion.isVersion2120OrLater(version)) {
- gerritConfig = new GerritConfigX();
+ gerritConfig = getGerritConfigFromServerInfo(monitor);
} else {
throw new GerritException("Failed to obtain Gerrit configuration"); //$NON-NLS-1$
}
@@ -315,6 +315,10 @@ public abstract class GerritClient extends ReviewsClient {
}
}
+ protected GerritConfigX getGerritConfigFromServerInfo(IProgressMonitor monitor) throws GerritException {
+ return new GerritConfigX();
+ }
+
public GerritConfiguration refreshConfig(IProgressMonitor monitor) throws GerritException {
refreshAllCachedProjectBranches(monitor);
configRefreshed = true;
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient212.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient212.java
new file mode 100644
index 00000000..233a4592
--- /dev/null
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient212.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.gerrit.core.client;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.mylyn.internal.gerrit.core.client.compat.DownloadSchemeX;
+import org.eclipse.mylyn.internal.gerrit.core.client.compat.GerritConfigX;
+import org.eclipse.mylyn.internal.gerrit.core.client.compat.SchemeInfo;
+import org.eclipse.mylyn.internal.gerrit.core.client.rest.DownloadSchemeInfo;
+import org.eclipse.mylyn.internal.gerrit.core.client.rest.ServerInfo;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.osgi.framework.Version;
+
+import com.google.gerrit.reviewdb.Project.NameKey;
+
+public class GerritClient212 extends GerritClient29 {
+
+ protected GerritClient212(TaskRepository repository, Version version) {
+ super(repository, version);
+ }
+
+ @Override
+ protected GerritConfigX getGerritConfigFromServerInfo(IProgressMonitor monitor) throws GerritException {
+ String query = "/config/server/info"; //$NON-NLS-1$/
+ org.eclipse.mylyn.internal.gerrit.core.client.rest.ServerInfo serverInfo = getRestClient()
+ .executeGetRestRequest(query, org.eclipse.mylyn.internal.gerrit.core.client.rest.ServerInfo.class,
+ monitor);
+
+ return convertServerInfoToGerritConfig(serverInfo);
+ }
+
+ private GerritConfigX convertServerInfoToGerritConfig(ServerInfo serverInfo) {
+ GerritConfigX config = new GerritConfigX();
+
+ // gerrit/all_projects + user -> wildproject
+ config.setWildProject(new NameKey(serverInfo.getGerrit().getRootProject()));
+
+ // download/schemes -> getGerritConfig().getDownloadSchemes
+ Map<DownloadSchemeX, SchemeInfo> schemes = new HashMap<>();
+
+ serverInfo.getDownload().getSchemes().entrySet().forEach(entry -> {
+ DownloadSchemeX scheme = DownloadSchemeX.fromString(entry.getKey());
+ if (scheme != null) {
+ DownloadSchemeInfo info = entry.getValue();
+ SchemeInfo schemeInfo = new SchemeInfo(info.getUrl(), info.isAuthRequired(), info.isAuthSupported(),
+ info.getCommands(), info.getCloneCommands());
+
+ schemes.put(scheme, schemeInfo);
+ }
+ });
+
+ config.setSchemes(schemes);
+
+ return config;
+ }
+}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/DownloadSchemeX.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/DownloadSchemeX.java
new file mode 100644
index 00000000..153ab508
--- /dev/null
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/DownloadSchemeX.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.gerrit.core.client.compat;
+
+public enum DownloadSchemeX {
+ ANON_HTTP("anonymous http"), HTTP("http"), GIT("git"), SSH("ssh"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private String scheme;
+
+ private DownloadSchemeX(String scheme) {
+ this.scheme = scheme;
+ }
+
+ @Override
+ public String toString() {
+ return scheme;
+ }
+
+ public static DownloadSchemeX fromString(String scheme) {
+ for (DownloadSchemeX value : values()) {
+ if (value.toString().equals(scheme)) {
+ return value;
+ }
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/GerritConfigX.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/GerritConfigX.java
index d6346f99..dd06d160 100644
--- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/GerritConfigX.java
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/GerritConfigX.java
@@ -12,7 +12,9 @@
package org.eclipse.mylyn.internal.gerrit.core.client.compat;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
import com.google.gerrit.common.data.GerritConfig;
@@ -26,6 +28,16 @@ public class GerritConfigX extends GerritConfig {
private String gitHttpUrl;
+ private Map<DownloadSchemeX, SchemeInfo> schemes;
+
+ public Map<DownloadSchemeX, SchemeInfo> getSchemes() {
+ return schemes;
+ }
+
+ public void setSchemes(Map<DownloadSchemeX, SchemeInfo> schemes) {
+ this.schemes = Collections.unmodifiableMap(schemes);
+ }
+
public List<CommentLink> getCommentLinks2() {
return commentLinks;
}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/SchemeInfo.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/SchemeInfo.java
new file mode 100644
index 00000000..af62fbed
--- /dev/null
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/compat/SchemeInfo.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.gerrit.core.client.compat;
+
+import java.util.Collections;
+import java.util.Map;
+
+public class SchemeInfo {
+ private final String url;
+
+ private final boolean authRequired;
+
+ private final boolean authSupported;
+
+ private final Map<String, String> commands;
+
+ private final Map<String, String> cloneCommands;
+
+ public SchemeInfo(String url, boolean authRequired, boolean authSupported, Map<String, String> commands,
+ Map<String, String> cloneCommands) {
+ this.url = url;
+ this.authRequired = authRequired;
+ this.authSupported = authSupported;
+ this.commands = Collections.unmodifiableMap(commands);
+ this.cloneCommands = Collections.unmodifiableMap(cloneCommands);
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public boolean isAuthRequired() {
+ return authRequired;
+ }
+
+ public boolean isAuthSupported() {
+ return authSupported;
+ }
+
+ public Map<String, String> getCommands() {
+ return commands;
+ }
+
+ public Map<String, String> getCloneCommands() {
+ return cloneCommands;
+ }
+}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/DownloadInfo.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/DownloadInfo.java
new file mode 100644
index 00000000..5bab7e8c
--- /dev/null
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/DownloadInfo.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.gerrit.core.client.rest;
+
+import java.util.Map;
+
+/**
+ * Data model object for
+ * <a href="https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#download-info">DownloadInfo</a>.
+ *
+ * @since 2.12
+ */
+public class DownloadInfo {
+ Map<String, DownloadSchemeInfo> schemes;
+
+ public Map<String, DownloadSchemeInfo> getSchemes() {
+ return schemes;
+ }
+}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/DownloadSchemeInfo.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/DownloadSchemeInfo.java
new file mode 100644
index 00000000..1f3ff685
--- /dev/null
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/DownloadSchemeInfo.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.gerrit.core.client.rest;
+
+import java.util.Map;
+
+/**
+ * Data model object for <a href=
+ * "https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#download-scheme-info">DownloadSchemeInfo</a>.
+ *
+ * @since 2.12
+ */
+public class DownloadSchemeInfo {
+ private String url;
+
+ private boolean is_auth_required;
+
+ private boolean is_auth_supported;
+
+ private Map<String, String> commands;
+
+ private Map<String, String> clone_commands;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public boolean isAuthRequired() {
+ return is_auth_required;
+ }
+
+ public boolean isAuthSupported() {
+ return is_auth_supported;
+ }
+
+ public Map<String, String> getCommands() {
+ return commands;
+ }
+
+ public Map<String, String> getCloneCommands() {
+ return clone_commands;
+ }
+}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/GerritInfo.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/GerritInfo.java
new file mode 100644
index 00000000..6c017065
--- /dev/null
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/GerritInfo.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.gerrit.core.client.rest;
+
+/**
+ * Data model object for
+ * <a href="https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#gerrit-info">GerritInfo</a>.
+ *
+ * @since 2.12
+ */
+public class GerritInfo {
+ private String all_projects_name;
+
+ private String all_projects;
+
+ public String getRootProject() {
+ return all_projects == null ? all_projects_name : all_projects;
+ }
+}
diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/ServerInfo.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/ServerInfo.java
new file mode 100644
index 00000000..ae27692e
--- /dev/null
+++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/rest/ServerInfo.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.gerrit.core.client.rest;
+
+/**
+ * Data model object for
+ * <a href="https://gerrit-review.googlesource.com/Documentation/rest-api-config.html#server-info">ServerInfo</a>.
+ *
+ * @since 2.12
+ */
+public class ServerInfo {
+ private GerritInfo gerrit;
+
+ private DownloadInfo download;
+
+ public GerritInfo getGerrit() {
+ return gerrit;
+ }
+
+ public DownloadInfo getDownload() {
+ return download;
+ }
+}
diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java
index 3384022e..c6abb018 100644
--- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java
+++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/core/client/GerritClientTest.java
@@ -30,8 +30,6 @@ import java.net.URLEncoder;
import java.util.EnumSet;
import java.util.List;
-import junit.framework.TestCase;
-
import org.apache.commons.httpclient.Cookie;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -44,7 +42,7 @@ import org.eclipse.mylyn.gerrit.tests.support.GerritHarness;
import org.eclipse.mylyn.internal.gerrit.core.GerritUtil;
import org.eclipse.mylyn.internal.gerrit.core.client.GerritAuthenticationState;
import org.eclipse.mylyn.internal.gerrit.core.client.GerritClient;
-import org.eclipse.mylyn.internal.gerrit.core.client.GerritClient29;
+import org.eclipse.mylyn.internal.gerrit.core.client.GerritClient212;
import org.eclipse.mylyn.internal.gerrit.core.client.GerritConfiguration;
import org.eclipse.mylyn.internal.gerrit.core.client.GerritException;
import org.eclipse.mylyn.internal.gerrit.core.client.GerritSystemInfo;
@@ -62,6 +60,8 @@ import com.google.gerrit.reviewdb.Patch.ChangeType;
import com.google.gerrit.reviewdb.Patch.Key;
import com.google.gerrit.reviewdb.PatchSet.Id;
+import junit.framework.TestCase;
+
/**
* @author Steffen Pingel
* @author Sascha Scholz
@@ -69,7 +69,7 @@ import com.google.gerrit.reviewdb.PatchSet.Id;
* @author Jacques Bouthillier
*/
public class GerritClientTest extends TestCase {
- public class TestGerritClient extends GerritClient29 {
+ public class TestGerritClient extends GerritClient212 {
public TestGerritClient(TaskRepository repository, AbstractWebLocation location) {
super(repository, GerritFixture.current().getGerritVersion());
@@ -131,6 +131,11 @@ public class GerritClientTest extends TestCase {
assertNotNull(config);
assertNotNull(config.getGerritConfig());
assertNotNull(config.getProjects());
+ assertNotNull(config.getGerritConfig().getWildProject());
+ assertEquals("All-Projects", config.getGerritConfig().getWildProject().toString());
+ if (client.getVersion().getMinor() >= 12) {
+ assertNotNull(config.getGerritConfig().getSchemes());
+ }
}
@Test
diff --git a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/support/GerritFixture.java b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/support/GerritFixture.java
index 3034bddd..72e40dd0 100644
--- a/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/support/GerritFixture.java
+++ b/org.eclipse.mylyn.gerrit.tests/src/org/eclipse/mylyn/gerrit/tests/support/GerritFixture.java
@@ -47,7 +47,8 @@ public class GerritFixture extends TestFixture {
public GerritFixture(FixtureConfiguration configuration) {
this(configuration.getUrl(), configuration.getVersion(), configuration.getInfo());
- supportsAnonymousAccess = "DEVELOPMENT_BECOME_ANY_ACCOUNT".equals(configuration.getProperties().get("authtype"));
+ supportsAnonymousAccess = "DEVELOPMENT_BECOME_ANY_ACCOUNT"
+ .equals(configuration.getProperties().get("authtype"));
}
public static GerritFixture current() {
@@ -57,6 +58,20 @@ public class GerritFixture extends TestFixture {
return current;
}
+ public static GerritFixture forVersion(int major, int minor) {
+
+ GerritFixture fixture = TestConfiguration.getDefault()
+ .discover(GerritFixture.class, "gerrit", false)
+ .stream()
+ .filter(f -> f.getGerritVersion().getMinor() >= minor && f.getGerritVersion().getMajor() >= major)
+ .findFirst()
+ .get();
+
+ fixture.activate();
+
+ return fixture;
+ }
+
@Override
protected GerritFixture activate() {
current = this;

Back to the top