Merge branch 'stable-3.2' into master
* stable-3.2:
Set current project name for EventListener events.
Change-Id: I5ef1e046be534d701b6b0aece8db4dc6e2e74e6f
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/InitIts.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/InitIts.java
index fbb6e39..91e84a1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/InitIts.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/InitIts.java
@@ -15,7 +15,7 @@
package com.googlesource.gerrit.plugins.its.base.its;
import com.google.common.base.Strings;
-import com.google.gerrit.common.data.AccessSection;
+import com.google.gerrit.entities.AccessSection;
import com.google.gerrit.pgm.init.api.AllProjectsConfig;
import com.google.gerrit.pgm.init.api.AllProjectsNameOnInitProvider;
import com.google.gerrit.pgm.init.api.ConsoleUI;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
index 3429ba4..668ff1e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
@@ -18,7 +18,7 @@
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Nullable;
-import com.google.gerrit.common.data.AccessSection;
+import com.google.gerrit.entities.AccessSection;
import com.google.gerrit.entities.Project;
import com.google.gerrit.entities.Project.NameKey;
import com.google.gerrit.extensions.annotations.PluginName;
@@ -274,7 +274,7 @@
"Cannot access %s configuration for plugin %s", projectName, pluginName);
}
}
- return new PluginConfig(pluginName, new Config());
+ return PluginConfig.create(pluginName, new Config(), null);
}
private List<CommentLinkInfo> getCommentLinkInfo(final String commentlinkName) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionController.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionController.java
index f565dc1..d2166a3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionController.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionController.java
@@ -90,7 +90,7 @@
}
if (!projectProperties.containsKey("its-project")) {
String project = projectProperties.get("project");
- logger.atSevere().log(
+ logger.atFinest().log(
"Could not process project event. No its-project associated with project %s. "
+ "Did you forget to configure the ITS project association in project.config?",
project);
diff --git a/src/main/resources/Documentation/config-rulebase-common.md b/src/main/resources/Documentation/config-rulebase-common.md
index c8ce22c..303aed6 100644
--- a/src/main/resources/Documentation/config-rulebase-common.md
+++ b/src/main/resources/Documentation/config-rulebase-common.md
@@ -3,6 +3,7 @@
[TOC]: # "Table of Contents"
### Table of Contents
+
- [Overview](#overview)
- [Rule Bases Scope](#rule-bases-scope)
- [Rules](#rules)
@@ -10,7 +11,6 @@
- [Event Properties](#event-properties)
- [Actions](#actions)
-
## Overview
In this part we describe how to specify which events in Gerrit (E.g.:
@@ -26,7 +26,7 @@
A simple rule bases file may look like
-```
+```ini
[rule "rule1"]
event-type = change-merged
action = add-standard-comment
@@ -103,6 +103,7 @@
is true either if they are defined in generic or project specific scope.
[rules-inheritance]: #rules-inheritance
+
### <a name="rules-inheritance">Rules inheritance</a>
For project specific rules, i.e., those defined on the `refs/meta/config`
@@ -152,7 +153,7 @@
The conditions are lines of the form
-```
+```ini
name = value1, value2, ..., valueN
```
@@ -162,7 +163,7 @@
having `subject`, or `footer-Bug`, the following condition can be
used:
-```
+```ini
association = subject,footer-Bug
```
@@ -171,7 +172,7 @@
example to match events that do not come with a `status` property
having `DRAFT`, the following condition can be used:
-```
+```ini
status = !,DRAFT
```
@@ -209,7 +210,7 @@
For example
- ```
+```ini
[rule "someRuleForBugzillaOnly"]
its-name = its-bugzilla
approvalCodeReview = -2
@@ -218,7 +219,7 @@
its-name = its-jira
approvalCodeReview = -2
action = add-comment Dear JIRA users, the change had a -2 Code-Review approval.
- ```
+```
would report the “Heya Bugzilla...” text only through its-bugzilla for
changes that had a -2 Code-Review and have an association through
@@ -461,7 +462,7 @@
`changerEmail`
: email address of the user that changed the WIP state
-`submitterName`
+`changerName`
: name of the user that changed the WIP state
`changerUsername`
@@ -478,7 +479,7 @@
`changerEmail`
: email address of the user that changed the private state
-`submitterName`
+`changerName`
: name of the user that changed the private state
`changerUsername`
@@ -585,7 +586,7 @@
Lines of the form
-```
+```ini
action = name param1 param2 ... paramN
```
@@ -620,7 +621,7 @@
So for example
-```
+```ini
action = add-comment This is a sample command
```
@@ -646,7 +647,7 @@
So for example
-```
+```ini
action = add-soy-comment TemplateName
```
@@ -655,7 +656,6 @@
example for what the soy template will look like (note @param is required with correct variables.)
-
```
{namespace etc.its.templates}
{template .TemplateName kind="text"}
@@ -679,7 +679,7 @@
Example with the event property `branch` and a field identified as `labels`:
-```
+```ini
action = add-property-to-field branch labels
```
@@ -693,7 +693,7 @@
Example with the event property `ref`:
-```
+```ini
action = create-version-from-property ref
```
@@ -705,6 +705,7 @@
This is useful when you want to trigger rules on a multiple past commits.
Available collectors are:
+
- `since-last-tag`: Collects all commits between the current ref and previous tag
To avoid to trigger issue actions twice for the same event, you should condition your rule on
@@ -712,11 +713,10 @@
Example:
-```
+```ini
action = fire-event-on-commits since-last-tag
```
-
### Action: log-event
The `log-event` action appends the event's properties to Gerrit's log.
@@ -725,7 +725,7 @@
adding the desired log level as parameter. Supported values are
`error`, `warn`, `info`, and `debug`). So for example
-```
+```ini
action = log-event error
```
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
index 433c43e..de86e86 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
@@ -51,7 +51,8 @@
private ItsConfig itsConfig;
private ItsFacadeFactory itsFacadeFactory;
- private Project project = new Project(Project.nameKey("myProject"));
+ private Project.NameKey projectName = Project.nameKey("myProject");
+ private Project project = Project.builder(projectName).build();
public void testOptional() throws CommitValidationException {
List<CommitValidationMessage> ret;
@@ -139,7 +140,7 @@
CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.SUGGESTED);
when(issueExtractor.getIssueIds("bug#4711")).thenReturn(new String[] {"4711"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(true);
ret = ivc.onCommitReceived(event);
@@ -160,7 +161,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.MANDATORY);
when(issueExtractor.getIssueIds("bug#4711")).thenReturn(new String[] {"4711"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(true);
ret = ivc.onCommitReceived(event);
@@ -182,7 +183,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.SUGGESTED);
when(issueExtractor.getIssueIds("bug#4711")).thenReturn(new String[] {"4711"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(false);
ret = ivc.onCommitReceived(event);
@@ -208,7 +209,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.MANDATORY);
when(issueExtractor.getIssueIds("bug#4711")).thenReturn(new String[] {"4711"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(false);
CommitValidationException thrown =
@@ -229,7 +230,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.SUGGESTED);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(true);
when(itsFacade.exists("42")).thenReturn(true);
@@ -251,7 +252,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.MANDATORY);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(true);
when(itsFacade.exists("42")).thenReturn(true);
@@ -275,7 +276,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.SUGGESTED);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(false);
when(itsFacade.exists("42")).thenReturn(true);
@@ -306,7 +307,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.MANDATORY);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(false);
when(itsFacade.exists("42")).thenReturn(true);
@@ -330,7 +331,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.SUGGESTED);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(false);
when(itsFacade.exists("42")).thenReturn(false);
@@ -361,7 +362,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.MANDATORY);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
when(itsFacade.exists("4711")).thenReturn(false);
when(itsFacade.exists("42")).thenReturn(true);
@@ -385,7 +386,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.SUGGESTED);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
doThrow(new IOException("InjectedEx1")).when(itsFacade).exists("4711");
when(itsFacade.exists("42")).thenReturn(false);
@@ -430,7 +431,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.MANDATORY);
when(issueExtractor.getIssueIds("bug#4711")).thenReturn(new String[] {"4711"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
doThrow(new IOException("InjectedEx1")).when(itsFacade).exists("4711");
ret = ivc.onCommitReceived(event);
@@ -461,7 +462,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.MANDATORY);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
doThrow(new IOException("InjectedEx1")).when(itsFacade).exists("4711");
when(itsFacade.exists("42")).thenReturn(false);
@@ -491,7 +492,7 @@
when(itsConfig.getItsAssociationPolicy()).thenReturn(ItsAssociationPolicy.MANDATORY);
when(issueExtractor.getIssueIds("bug#4711, bug#42")).thenReturn(new String[] {"4711", "42"});
- when(itsFacadeFactory.getFacade(project.getNameKey())).thenReturn(itsFacade);
+ when(itsFacadeFactory.getFacade(projectName)).thenReturn(itsFacade);
doThrow(new IOException("InjectedEx1")).when(itsFacade).exists("4711");
when(itsFacade.exists("42")).thenReturn(true);