Merge branch 'stable-2.11'

* stable-2.11:
  Fix wrong date/time for commits in refs/meta/config branch
  Fix disabling of git ssh 'download' scheme within DefaultCommandModule

Change-Id: Id9f12bf2bcd35092231784eecec607a0574d357e
This commit is contained in:
David Pursehouse 2015-07-06 09:46:09 +09:00
commit 79ea7d3942
4 changed files with 32 additions and 14 deletions

View File

@ -49,6 +49,7 @@ import com.google.gerrit.server.config.AuthConfig;
import com.google.gerrit.server.config.AuthConfigModule;
import com.google.gerrit.server.config.CanonicalWebUrlModule;
import com.google.gerrit.server.config.CanonicalWebUrlProvider;
import com.google.gerrit.server.config.DownloadConfig;
import com.google.gerrit.server.config.GerritGlobalModule;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.RestCacheAdminModule;
@ -402,8 +403,8 @@ public class Daemon extends SiteProgram {
if (!test) {
modules.add(new SshHostKeyModule());
}
modules.add(new DefaultCommandModule(slave));
modules.add(new DefaultCommandModule(slave,
sysInjector.getInstance(DownloadConfig.class)));
return sysInjector.createChildInjector(modules);
}

View File

@ -79,7 +79,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
}
private final Config gerritConfig;
private final MetaDataUpdate.User metaDataUpdateFactory;
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
private final ProjectCache projectCache;
private final GitRepositoryManager gitMgr;
private final ProjectState.Factory projectStateFactory;
@ -93,7 +93,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
@Inject
PutConfig(@GerritServerConfig Config gerritConfig,
MetaDataUpdate.User metaDataUpdateFactory,
Provider<MetaDataUpdate.User> metaDataUpdateFactory,
ProjectCache projectCache,
GitRepositoryManager gitMgr,
ProjectState.Factory projectStateFactory,
@ -138,7 +138,7 @@ public class PutConfig implements RestModifyView<ProjectResource, Input> {
final MetaDataUpdate md;
try {
md = metaDataUpdateFactory.create(projectName);
md = metaDataUpdateFactory.get().create(projectName);
} catch (RepositoryNotFoundException notFound) {
throw new ResourceNotFoundException(projectName.get());
} catch (IOException e) {

View File

@ -14,6 +14,8 @@
package com.google.gerrit.sshd.commands;
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
import com.google.gerrit.server.config.DownloadConfig;
import com.google.gerrit.sshd.CommandModule;
import com.google.gerrit.sshd.CommandName;
import com.google.gerrit.sshd.Commands;
@ -23,8 +25,11 @@ import com.google.gerrit.sshd.SuExec;
/** Register the commands a Gerrit server supports. */
public class DefaultCommandModule extends CommandModule {
public DefaultCommandModule(boolean slave) {
private final DownloadConfig downloadConfig;
public DefaultCommandModule(boolean slave, DownloadConfig downloadCfg) {
slaveMode = slave;
downloadConfig = downloadCfg;
}
@Override
@ -68,10 +73,12 @@ public class DefaultCommandModule extends CommandModule {
command("scp").to(ScpCommand.class);
// Honor the legacy hyphenated forms as aliases for the non-hyphenated forms
command("git-upload-pack").to(Commands.key(git, "upload-pack"));
command(git, "upload-pack").to(Upload.class);
command("git-upload-archive").to(Commands.key(git, "upload-archive"));
command(git, "upload-archive").to(UploadArchive.class);
if (sshEnabled()) {
command("git-upload-pack").to(Commands.key(git, "upload-pack"));
command(git, "upload-pack").to(Upload.class);
command("git-upload-archive").to(Commands.key(git, "upload-archive"));
command(git, "upload-archive").to(UploadArchive.class);
}
command("suexec").to(SuExec.class);
listener().to(ShowCaches.StartupListener.class);
@ -87,9 +94,11 @@ public class DefaultCommandModule extends CommandModule {
command(git, "receive-pack").to(NotSupportedInSlaveModeFailureCommand.class);
command(gerrit, "test-submit").to(NotSupportedInSlaveModeFailureCommand.class);
} else {
command("git-receive-pack").to(Commands.key(git, "receive-pack"));
command("gerrit-receive-pack").to(Commands.key(git, "receive-pack"));
command(git, "receive-pack").to(Commands.key(gerrit, "receive-pack"));
if (sshEnabled()) {
command("git-receive-pack").to(Commands.key(git, "receive-pack"));
command("gerrit-receive-pack").to(Commands.key(git, "receive-pack"));
command(git, "receive-pack").to(Commands.key(gerrit, "receive-pack"));
}
command(gerrit, "test-submit").toProvider(
new DispatchCommandProvider(testSubmit));
}
@ -114,4 +123,10 @@ public class DefaultCommandModule extends CommandModule {
alias(logging, "ls", ListLoggingLevelCommand.class);
alias(logging, "set", SetLoggingLevelCommand.class);
}
private boolean sshEnabled() {
return downloadConfig.getDownloadSchemes().contains(DownloadScheme.SSH)
|| downloadConfig.getDownloadSchemes().contains(
DownloadScheme.DEFAULT_DOWNLOADS);
}
}

View File

@ -32,6 +32,7 @@ import com.google.gerrit.server.change.ChangeCleanupRunner;
import com.google.gerrit.server.config.AuthConfig;
import com.google.gerrit.server.config.AuthConfigModule;
import com.google.gerrit.server.config.CanonicalWebUrlModule;
import com.google.gerrit.server.config.DownloadConfig;
import com.google.gerrit.server.config.GerritGlobalModule;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.GerritServerConfigModule;
@ -330,7 +331,8 @@ public class WebAppInitializer extends GuiceServletContextListener
final List<Module> modules = new ArrayList<>();
modules.add(sysInjector.getInstance(SshModule.class));
modules.add(new SshHostKeyModule());
modules.add(new DefaultCommandModule(false));
modules.add(new DefaultCommandModule(false,
sysInjector.getInstance(DownloadConfig.class)));
return sysInjector.createChildInjector(modules);
}