Merge "Fix ssh:// advertised URL in RevisionInfo fetch map of /detail"
This commit is contained in:
commit
41a12b49bf
@ -74,14 +74,12 @@ import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.gerrit.server.ssh.SshAdvertisedAddresses;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import com.jcraft.jsch.HostKey;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -103,11 +101,16 @@ public class ChangeJson {
|
||||
static class Urls {
|
||||
final String git;
|
||||
final String http;
|
||||
final String ssh;
|
||||
|
||||
@Inject
|
||||
Urls(@GerritServerConfig Config cfg) {
|
||||
Urls(@GerritServerConfig Config cfg,
|
||||
@SshAdvertisedAddresses List<String> sshAddresses) {
|
||||
this.git = ensureSlash(cfg.getString("gerrit", null, "canonicalGitUrl"));
|
||||
this.http = ensureSlash(cfg.getString("gerrit", null, "gitHttpUrl"));
|
||||
this.ssh = !sshAddresses.isEmpty()
|
||||
? ensureSlash("ssh://" + sshAddresses.get(0))
|
||||
: null;
|
||||
}
|
||||
|
||||
private static String ensureSlash(String in) {
|
||||
@ -133,7 +136,6 @@ public class ChangeJson {
|
||||
private final Revisions revisions;
|
||||
|
||||
private ChangeControl.Factory changeControlUserFactory;
|
||||
private SshInfo sshInfo;
|
||||
private EnumSet<ListChangesOption> options;
|
||||
private AccountInfo.Loader accountLoader;
|
||||
private ChangeControl lastControl;
|
||||
@ -180,11 +182,6 @@ public class ChangeJson {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChangeJson setSshInfo(SshInfo info) {
|
||||
sshInfo = info;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChangeJson setChangeControlFactory(ChangeControl.Factory cf) {
|
||||
changeControlUserFactory = cf;
|
||||
return this;
|
||||
@ -826,11 +823,9 @@ public class ChangeJson {
|
||||
+ cd.change(db).getProject().get(), refName));
|
||||
}
|
||||
}
|
||||
if (sshInfo != null && !sshInfo.getHostKeys().isEmpty()) {
|
||||
HostKey host = sshInfo.getHostKeys().get(0);
|
||||
r.put("ssh", new FetchInfo(String.format(
|
||||
"ssh://%s/%s",
|
||||
host.getHost(), cd.change(db).getProject().get()),
|
||||
if (urls.ssh != null) {
|
||||
r.put("ssh", new FetchInfo(
|
||||
urls.ssh + cd.change(db).getProject().get(),
|
||||
refName));
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ import com.google.gerrit.server.change.ChangeJson;
|
||||
import com.google.gerrit.server.change.ChangeJson.ChangeInfo;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.query.QueryParseException;
|
||||
import com.google.gerrit.server.ssh.SshInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@ -81,13 +80,11 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
||||
@Inject
|
||||
QueryChanges(ChangeJson json,
|
||||
QueryProcessor qp,
|
||||
SshInfo sshInfo,
|
||||
ChangeControl.Factory cf) {
|
||||
this.json = json;
|
||||
this.imp = qp;
|
||||
|
||||
options = EnumSet.noneOf(ListChangesOption.class);
|
||||
json.setSshInfo(sshInfo);
|
||||
json.setChangeControlFactory(cf);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user