Merge branch 'stable-2.9'

* stable-2.9:
  Only permit current patch set to edit the commit message
  Use Provider for IdentifiedUser in CreateBranch constructor
  Split PGPEncryptedDataGenerator creation out into a utility method
  ChangeScreen2: Only reset the commit message text on cancel
  Fix log spew caused by DeleteBranch constructor
  Add Documentation menu entry for Project Owner Guide
  Mention project-specific themes in the project owner guide
  Added global request handlers to SshDaemon
This commit is contained in:
Shawn Pearce
2014-04-25 09:49:50 -07:00
7 changed files with 39 additions and 4 deletions

View File

@@ -547,6 +547,18 @@ Project-specific download commands that are defined on a parent project
are inherited by the child projects. A child project can overwrite an are inherited by the child projects. A child project can overwrite an
inherited download command, or remove it by assigning no value to it. inherited download command, or remove it by assigning no value to it.
[[theme]]
== Theme
Gerrit supports project-specific themes for customizing the appearance
of the change screen and the diff screens. It is possible to define an
HTML header and footer and to adapt Gerrit's CSS. Details about themes
are explained in the link:config-themes.html[Themes] section.
Project-specific themes can only be installed by Gerrit administrators
since the theme files must be copied into the Gerrit installation
folder.
[[tool-integration]] [[tool-integration]]
== Integration with other tools == Integration with other tools

View File

@@ -689,6 +689,7 @@ public class Gerrit implements EntryPoint {
addDocLink(m, C.menuDocumentationUpload(), "user-upload.html"); addDocLink(m, C.menuDocumentationUpload(), "user-upload.html");
addDocLink(m, C.menuDocumentationAccess(), "access-control.html"); addDocLink(m, C.menuDocumentationAccess(), "access-control.html");
addDocLink(m, C.menuDocumentationAPI(), "rest-api.html"); addDocLink(m, C.menuDocumentationAPI(), "rest-api.html");
addDocLink(m, C.menuDocumentationProjectOwnerGuide(), "intro-project-owner.html");
menuLeft.add(m, C.menuDocumentation()); menuLeft.add(m, C.menuDocumentation());
} }

View File

@@ -91,6 +91,7 @@ public interface GerritConstants extends Constants {
String menuDocumentationUpload(); String menuDocumentationUpload();
String menuDocumentationAccess(); String menuDocumentationAccess();
String menuDocumentationAPI(); String menuDocumentationAPI();
String menuDocumentationProjectOwnerGuide();
String searchHint(); String searchHint();
String searchButton(); String searchButton();

View File

@@ -74,6 +74,7 @@ menuDocumentationSearch = Searching
menuDocumentationUpload = Uploading menuDocumentationUpload = Uploading
menuDocumentationAccess = Access Controls menuDocumentationAccess = Access Controls
menuDocumentationAPI = REST API menuDocumentationAPI = REST API
menuDocumentationProjectOwnerGuide = Project Owner Guide
searchHint = Search term searchHint = Search term
searchButton = Search searchButton = Search

View File

@@ -65,6 +65,11 @@ class EditMessage implements RestModifyView<RevisionResource, Input>,
ResourceNotFoundException, EmailException, OrmException, IOException { ResourceNotFoundException, EmailException, OrmException, IOException {
if (Strings.isNullOrEmpty(input.message)) { if (Strings.isNullOrEmpty(input.message)) {
throw new BadRequestException("message must be non-empty"); throw new BadRequestException("message must be non-empty");
} else if (!rsrc.getPatchSet().getId()
.equals(rsrc.getChange().currentPatchSetId())) {
throw new ResourceConflictException(String.format(
"revision %s is not current revision",
rsrc.getPatchSet().getRevision().get()));
} }
try { try {
return json.format(changeUtil.editCommitMessage( return json.format(changeUtil.editCommitMessage(

View File

@@ -32,6 +32,7 @@ import com.google.gerrit.server.project.CreateBranch.Input;
import com.google.gerrit.server.project.ListBranches.BranchInfo; import com.google.gerrit.server.project.ListBranches.BranchInfo;
import com.google.gerrit.server.util.MagicBranch; import com.google.gerrit.server.util.MagicBranch;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted; import com.google.inject.assistedinject.Assisted;
import org.eclipse.jgit.errors.IncorrectObjectTypeException; import org.eclipse.jgit.errors.IncorrectObjectTypeException;
@@ -64,14 +65,15 @@ public class CreateBranch implements RestModifyView<ProjectResource, Input> {
CreateBranch create(String ref); CreateBranch create(String ref);
} }
private final IdentifiedUser identifiedUser; private final Provider<IdentifiedUser> identifiedUser;
private final GitRepositoryManager repoManager; private final GitRepositoryManager repoManager;
private final GitReferenceUpdated referenceUpdated; private final GitReferenceUpdated referenceUpdated;
private final ChangeHooks hooks; private final ChangeHooks hooks;
private String ref; private String ref;
@Inject @Inject
CreateBranch(IdentifiedUser identifiedUser, GitRepositoryManager repoManager, CreateBranch(Provider<IdentifiedUser> identifiedUser,
GitRepositoryManager repoManager,
GitReferenceUpdated referenceUpdated, ChangeHooks hooks, GitReferenceUpdated referenceUpdated, ChangeHooks hooks,
@Assisted String ref) { @Assisted String ref) {
this.identifiedUser = identifiedUser; this.identifiedUser = identifiedUser;
@@ -135,7 +137,7 @@ public class CreateBranch implements RestModifyView<ProjectResource, Input> {
final RefUpdate u = repo.updateRef(ref); final RefUpdate u = repo.updateRef(ref);
u.setExpectedOldObjectId(ObjectId.zeroId()); u.setExpectedOldObjectId(ObjectId.zeroId());
u.setNewObjectId(object.copy()); u.setNewObjectId(object.copy());
u.setRefLogIdent(identifiedUser.newRefLogIdent()); u.setRefLogIdent(identifiedUser.get().newRefLogIdent());
u.setRefLogMessage("created via REST from " + input.revision, false); u.setRefLogMessage("created via REST from " + input.revision, false);
final RefUpdate.Result result = u.update(rw); final RefUpdate.Result result = u.update(rw);
switch (result) { switch (result) {
@@ -143,7 +145,7 @@ public class CreateBranch implements RestModifyView<ProjectResource, Input> {
case NEW: case NEW:
case NO_CHANGE: case NO_CHANGE:
referenceUpdated.fire(name.getParentKey(), u); referenceUpdated.fire(name.getParentKey(), u);
hooks.doRefUpdatedHook(name, u, identifiedUser.getAccount()); hooks.doRefUpdatedHook(name, u, identifiedUser.get().getAccount());
break; break;
case LOCK_FAILURE: case LOCK_FAILURE:
if (repo.getRef(ref) != null) { if (repo.getRef(ref) != null) {

View File

@@ -45,6 +45,7 @@ import org.apache.sshd.common.ForwardingFilter;
import org.apache.sshd.common.KeyExchange; import org.apache.sshd.common.KeyExchange;
import org.apache.sshd.common.KeyPairProvider; import org.apache.sshd.common.KeyPairProvider;
import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.RequestHandler;
import org.apache.sshd.common.Session; import org.apache.sshd.common.Session;
import org.apache.sshd.common.Signature; import org.apache.sshd.common.Signature;
import org.apache.sshd.common.SshdSocketAddress; import org.apache.sshd.common.SshdSocketAddress;
@@ -80,6 +81,7 @@ import org.apache.sshd.common.random.BouncyCastleRandom;
import org.apache.sshd.common.random.JceRandom; import org.apache.sshd.common.random.JceRandom;
import org.apache.sshd.common.random.SingletonRandomFactory; import org.apache.sshd.common.random.SingletonRandomFactory;
import org.apache.sshd.common.session.AbstractSession; import org.apache.sshd.common.session.AbstractSession;
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.signature.SignatureDSA; import org.apache.sshd.common.signature.SignatureDSA;
import org.apache.sshd.common.signature.SignatureRSA; import org.apache.sshd.common.signature.SignatureRSA;
import org.apache.sshd.common.util.Buffer; import org.apache.sshd.common.util.Buffer;
@@ -92,6 +94,10 @@ import org.apache.sshd.server.auth.UserAuthPublicKey;
import org.apache.sshd.server.auth.gss.GSSAuthenticator; import org.apache.sshd.server.auth.gss.GSSAuthenticator;
import org.apache.sshd.server.auth.gss.UserAuthGSS; import org.apache.sshd.server.auth.gss.UserAuthGSS;
import org.apache.sshd.server.channel.ChannelSession; import org.apache.sshd.server.channel.ChannelSession;
import org.apache.sshd.server.global.CancelTcpipForwardHandler;
import org.apache.sshd.server.global.KeepAliveHandler;
import org.apache.sshd.server.global.NoMoreSessionsHandler;
import org.apache.sshd.server.global.TcpipForwardHandler;
import org.apache.sshd.server.kex.DHG1; import org.apache.sshd.server.kex.DHG1;
import org.apache.sshd.server.kex.DHG14; import org.apache.sshd.server.kex.DHG14;
import org.apache.sshd.server.session.SessionFactory; import org.apache.sshd.server.session.SessionFactory;
@@ -149,6 +155,7 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
private volatile IoAcceptor acceptor; private volatile IoAcceptor acceptor;
private final Config cfg; private final Config cfg;
@SuppressWarnings("unchecked")
@Inject @Inject
SshDaemon(final CommandFactory commandFactory, final NoShell noShell, SshDaemon(final CommandFactory commandFactory, final NoShell noShell,
final PublickeyAuthenticator userAuth, final PublickeyAuthenticator userAuth,
@@ -257,6 +264,12 @@ public class SshDaemon extends SshServer implements SshInfo, LifecycleListener {
return new GerritServerSession(server, ioSession); return new GerritServerSession(server, ioSession);
} }
}); });
setGlobalRequestHandlers(Arrays.<RequestHandler<ConnectionService>> asList(
new KeepAliveHandler(),
new NoMoreSessionsHandler(),
new TcpipForwardHandler(),
new CancelTcpipForwardHandler()
));
hostKeys = computeHostKeys(); hostKeys = computeHostKeys();
} }