Merge branch 'stable-3.0' into stable-3.1
* stable-3.0: Fix method name to register custom event types in plugins Don't send mails on publish change edits for WIP changes PatchSetInserter: allow to set "sendEmail" bit Set version to 2.16.17-SNAPSHOT Set version to 2.16.16 CreateChange#getCommitMessage: Remove unused parameters and variable Remove MessageOfTheDay extension Revert "Add MessageOfTheDay-entries to ServerInfo" Revert "Add UI element to display messages of the day" Revert "Document MessageOfTheDay extension" Tests: Use helper method for config change Document MessageOfTheDay extension Add UI element to display messages of the day Add MessageOfTheDay-entries to ServerInfo Change-Id: Iceb5facff6b832c33fd9c991bf92a48446c844e9
This commit is contained in:
		| @@ -475,9 +475,9 @@ class MyPlugin { | |||||||
| ---- | ---- | ||||||
|  |  | ||||||
| Plugins which define new Events should register them via the | Plugins which define new Events should register them via the | ||||||
| `com.google.gerrit.server.events.EventTypes.registerClass()` | `com.google.gerrit.server.events.EventTypes.register()` method. | ||||||
| method. This will make the EventType known to the system. | This will make the EventType known to the system. Deserializing | ||||||
| Deserializing events with the | events with the | ||||||
| `com.google.gerrit.server.events.EventDeserializer` class requires | `com.google.gerrit.server.events.EventDeserializer` class requires | ||||||
| that the event be registered in EventTypes. | that the event be registered in EventTypes. | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,63 +0,0 @@ | |||||||
| // Copyright (C) 2014 The Android Open Source Project |  | ||||||
| // |  | ||||||
| // Licensed under the Apache License, Version 2.0 (the "License"); |  | ||||||
| // you may not use this file except in compliance with the License. |  | ||||||
| // You may obtain a copy of the License at |  | ||||||
| // |  | ||||||
| // http://www.apache.org/licenses/LICENSE-2.0 |  | ||||||
| // |  | ||||||
| // Unless required by applicable law or agreed to in writing, software |  | ||||||
| // distributed under the License is distributed on an "AS IS" BASIS, |  | ||||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |  | ||||||
| // See the License for the specific language governing permissions and |  | ||||||
| // limitations under the License. |  | ||||||
|  |  | ||||||
| package com.google.gerrit.extensions.systemstatus; |  | ||||||
|  |  | ||||||
| import com.google.gerrit.extensions.annotations.ExtensionPoint; |  | ||||||
| import java.util.Calendar; |  | ||||||
| import java.util.Date; |  | ||||||
| import java.util.TimeZone; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * Supplies a message of the day when the page is first loaded. |  | ||||||
|  * |  | ||||||
|  * <pre> |  | ||||||
|  * DynamicSet.bind(binder(), MessageOfTheDay.class).to(MyMessage.class); |  | ||||||
|  * </pre> |  | ||||||
|  */ |  | ||||||
| @ExtensionPoint |  | ||||||
| public abstract class MessageOfTheDay { |  | ||||||
|   /** |  | ||||||
|    * Retrieve the message of the day as an HTML fragment. |  | ||||||
|    * |  | ||||||
|    * @return message as an HTML fragment; null if no message is available. |  | ||||||
|    */ |  | ||||||
|   public abstract String getHtmlMessage(); |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * Unique identifier for this message. |  | ||||||
|    * |  | ||||||
|    * <p>Messages with the same identifier will be hidden from the user until redisplay has occurred. |  | ||||||
|    * |  | ||||||
|    * @return unique message identifier. This identifier should be unique within the server. |  | ||||||
|    */ |  | ||||||
|   public abstract String getMessageId(); |  | ||||||
|  |  | ||||||
|   /** |  | ||||||
|    * When should the message be displayed? |  | ||||||
|    * |  | ||||||
|    * <p>Default implementation returns {@code tomorrow at 00:00:00 GMT}. |  | ||||||
|    * |  | ||||||
|    * @return a future date after which the message should be redisplayed. |  | ||||||
|    */ |  | ||||||
|   public Date getRedisplay() { |  | ||||||
|     Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); |  | ||||||
|     cal.set(Calendar.HOUR_OF_DAY, 0); |  | ||||||
|     cal.set(Calendar.MINUTE, 0); |  | ||||||
|     cal.set(Calendar.SECOND, 0); |  | ||||||
|     cal.set(Calendar.MILLISECOND, 0); |  | ||||||
|     cal.add(Calendar.DAY_OF_MONTH, 1); |  | ||||||
|     return cal.getTime(); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| @@ -61,7 +61,6 @@ import com.google.gerrit.extensions.events.WorkInProgressStateChangedListener; | |||||||
| import com.google.gerrit.extensions.registration.DynamicItem; | import com.google.gerrit.extensions.registration.DynamicItem; | ||||||
| import com.google.gerrit.extensions.registration.DynamicMap; | import com.google.gerrit.extensions.registration.DynamicMap; | ||||||
| import com.google.gerrit.extensions.registration.DynamicSet; | import com.google.gerrit.extensions.registration.DynamicSet; | ||||||
| import com.google.gerrit.extensions.systemstatus.MessageOfTheDay; |  | ||||||
| import com.google.gerrit.extensions.validators.CommentValidator; | import com.google.gerrit.extensions.validators.CommentValidator; | ||||||
| import com.google.gerrit.extensions.webui.BranchWebLink; | import com.google.gerrit.extensions.webui.BranchWebLink; | ||||||
| import com.google.gerrit.extensions.webui.DiffWebLink; | import com.google.gerrit.extensions.webui.DiffWebLink; | ||||||
| @@ -360,7 +359,6 @@ public class GerritGlobalModule extends FactoryModule { | |||||||
|     DynamicItem.itemOf(binder(), AvatarProvider.class); |     DynamicItem.itemOf(binder(), AvatarProvider.class); | ||||||
|     DynamicSet.setOf(binder(), LifecycleListener.class); |     DynamicSet.setOf(binder(), LifecycleListener.class); | ||||||
|     DynamicSet.setOf(binder(), TopMenu.class); |     DynamicSet.setOf(binder(), TopMenu.class); | ||||||
|     DynamicSet.setOf(binder(), MessageOfTheDay.class); |  | ||||||
|     DynamicMap.mapOf(binder(), DownloadScheme.class); |     DynamicMap.mapOf(binder(), DownloadScheme.class); | ||||||
|     DynamicMap.mapOf(binder(), DownloadCommand.class); |     DynamicMap.mapOf(binder(), DownloadCommand.class); | ||||||
|     DynamicMap.mapOf(binder(), CloneCommand.class); |     DynamicMap.mapOf(binder(), CloneCommand.class); | ||||||
|   | |||||||
| @@ -168,7 +168,10 @@ public class ChangeEditUtil { | |||||||
|  |  | ||||||
|       RevCommit squashed = squashEdit(rw, oi, edit.getEditCommit(), basePatchSet); |       RevCommit squashed = squashEdit(rw, oi, edit.getEditCommit(), basePatchSet); | ||||||
|       PatchSet.Id psId = ChangeUtil.nextPatchSetId(repo, change.currentPatchSetId()); |       PatchSet.Id psId = ChangeUtil.nextPatchSetId(repo, change.currentPatchSetId()); | ||||||
|       PatchSetInserter inserter = patchSetInserterFactory.create(notes, psId, squashed); |       PatchSetInserter inserter = | ||||||
|  |           patchSetInserterFactory | ||||||
|  |               .create(notes, psId, squashed) | ||||||
|  |               .setSendEmail(!change.isWorkInProgress()); | ||||||
|  |  | ||||||
|       StringBuilder message = |       StringBuilder message = | ||||||
|           new StringBuilder("Patch Set ").append(inserter.getPatchSetId().get()).append(": "); |           new StringBuilder("Patch Set ").append(inserter.getPatchSetId().get()).append(": "); | ||||||
|   | |||||||
| @@ -142,8 +142,11 @@ public class ChangeEditIT extends AbstractDaemonTest { | |||||||
|   public void publishEdit() throws Exception { |   public void publishEdit() throws Exception { | ||||||
|     createArbitraryEditFor(changeId); |     createArbitraryEditFor(changeId); | ||||||
|  |  | ||||||
|  |     AddReviewerInput in = new AddReviewerInput(); | ||||||
|  |     in.reviewer = user.email(); | ||||||
|  |     gApi.changes().id(changeId).addReviewer(in); | ||||||
|  |  | ||||||
|     PublishChangeEditInput publishInput = new PublishChangeEditInput(); |     PublishChangeEditInput publishInput = new PublishChangeEditInput(); | ||||||
|     publishInput.notify = NotifyHandling.NONE; |  | ||||||
|     gApi.changes().id(changeId).edit().publish(publishInput); |     gApi.changes().id(changeId).edit().publish(publishInput); | ||||||
|  |  | ||||||
|     assertThat(getEdit(changeId)).isAbsent(); |     assertThat(getEdit(changeId)).isAbsent(); | ||||||
| @@ -160,8 +163,10 @@ public class ChangeEditIT extends AbstractDaemonTest { | |||||||
|     assertThat(info.messages).isNotEmpty(); |     assertThat(info.messages).isNotEmpty(); | ||||||
|     assertThat(Iterables.getLast(info.messages).tag) |     assertThat(Iterables.getLast(info.messages).tag) | ||||||
|         .isEqualTo(ChangeMessagesUtil.TAG_UPLOADED_PATCH_SET); |         .isEqualTo(ChangeMessagesUtil.TAG_UPLOADED_PATCH_SET); | ||||||
|  |     assertThat(sender.getMessages()).isNotEmpty(); | ||||||
|  |  | ||||||
|     // Move the change to WIP, repeat, and verify. |     // Move the change to WIP, repeat, and verify. | ||||||
|  |     sender.clear(); | ||||||
|     gApi.changes().id(changeId).setWorkInProgress(); |     gApi.changes().id(changeId).setWorkInProgress(); | ||||||
|     createEmptyEditFor(changeId); |     createEmptyEditFor(changeId); | ||||||
|     gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW2)); |     gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW2)); | ||||||
| @@ -170,6 +175,7 @@ public class ChangeEditIT extends AbstractDaemonTest { | |||||||
|     assertThat(info.messages).isNotEmpty(); |     assertThat(info.messages).isNotEmpty(); | ||||||
|     assertThat(Iterables.getLast(info.messages).tag) |     assertThat(Iterables.getLast(info.messages).tag) | ||||||
|         .isEqualTo(ChangeMessagesUtil.TAG_UPLOADED_WIP_PATCH_SET); |         .isEqualTo(ChangeMessagesUtil.TAG_UPLOADED_WIP_PATCH_SET); | ||||||
|  |     assertThat(sender.getMessages()).isEmpty(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Test |   @Test | ||||||
|   | |||||||
| @@ -57,7 +57,6 @@ import com.google.gerrit.acceptance.testsuite.request.RequestScopeOperations; | |||||||
| import com.google.gerrit.common.Nullable; | import com.google.gerrit.common.Nullable; | ||||||
| import com.google.gerrit.common.data.Permission; | import com.google.gerrit.common.data.Permission; | ||||||
| import com.google.gerrit.entities.Account; | import com.google.gerrit.entities.Account; | ||||||
| import com.google.gerrit.entities.BooleanProjectConfig; |  | ||||||
| import com.google.gerrit.entities.BranchNameKey; | import com.google.gerrit.entities.BranchNameKey; | ||||||
| import com.google.gerrit.entities.Change; | import com.google.gerrit.entities.Change; | ||||||
| import com.google.gerrit.entities.PatchSet; | import com.google.gerrit.entities.PatchSet; | ||||||
| @@ -645,14 +644,7 @@ public abstract class AbstractSubmit extends AbstractDaemonTest { | |||||||
|     //  | |     //  | | ||||||
|     // C0 -- Master |     // C0 -- Master | ||||||
|     // |     // | ||||||
|     try (ProjectConfigUpdate u = updateProject(project)) { |     enableCreateNewChangeForAllNotInTarget(); | ||||||
|       u.getConfig() |  | ||||||
|           .getProject() |  | ||||||
|           .setBooleanConfig( |  | ||||||
|               BooleanProjectConfig.CREATE_NEW_CHANGE_FOR_ALL_NOT_IN_TARGET, |  | ||||||
|               InheritableBoolean.TRUE); |  | ||||||
|       u.save(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     PushOneCommit push1 = |     PushOneCommit push1 = | ||||||
|         pushFactory.create(admin.newIdent(), testRepo, PushOneCommit.SUBJECT, "a.txt", "content"); |         pushFactory.create(admin.newIdent(), testRepo, PushOneCommit.SUBJECT, "a.txt", "content"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 David Pursehouse
					David Pursehouse