From b6ec88251fc08f15802c55a2fdbc2a37bffcf969 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 18 Jun 2020 09:52:35 +0900 Subject: [PATCH 1/6] RestApiServlet: Log JSON parse error at debug level Change-Id: I13bb020015dd44498cfcaa5745cf64c925fc976b --- java/com/google/gerrit/httpd/restapi/RestApiServlet.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java index 2b99d702e5..623d31d7d7 100644 --- a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java +++ b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java @@ -544,6 +544,7 @@ public class RestApiServlet extends HttpServlet { } } } catch (MalformedJsonException | JsonParseException e) { + logger.atFine().withCause(e).log("REST call failed on JSON parsing"); responseBytes = replyError( req, res, status = SC_BAD_REQUEST, "Invalid " + JSON_TYPE + " in request", e); From 4d7f99154a7813fff53c16adbb05c592140f0787 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 18 Jun 2020 13:02:56 +0900 Subject: [PATCH 2/6] Fix typos in test.submit_rule and test.submit_type examples Change-Id: Ia85b736a1bfdb6d349c5ba75788d5656a0f17f33 --- Documentation/rest-api-changes.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/rest-api-changes.txt b/Documentation/rest-api-changes.txt index 67b036352f..d6f101576c 100644 --- a/Documentation/rest-api-changes.txt +++ b/Documentation/rest-api-changes.txt @@ -4288,7 +4288,7 @@ a project-specific rule. .Request ---- POST /changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/revisions/current/test.submit_type HTTP/1.0 - Content-Type: text/plain; charset-UTF-8 + Content-Type: text/plain; charset=UTF-8 submit_type(cherry_pick). ---- @@ -4319,7 +4319,7 @@ a project-specific rule. .Request ---- POST /changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/revisions/current/test.submit_rule?filters=SKIP HTTP/1.0 - Content-Type: text/plain; charset-UTF-8 + Content-Type: text/plain; charset=UTF-8 submit_rule(submit(R)) :- R = label('Any-Label-Name', reject(_)). From a414e5b82d8af3af9dcbb05f5ef2532642974a76 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 18 Jun 2020 13:54:28 +0900 Subject: [PATCH 3/6] TestSubmitRule: Enable logErrors when debug logging is enabled Change-Id: I3741158ada2dcc8bd3988535e3db70b0651e8936 --- .../google/gerrit/server/restapi/change/TestSubmitRule.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/com/google/gerrit/server/restapi/change/TestSubmitRule.java b/java/com/google/gerrit/server/restapi/change/TestSubmitRule.java index c7eb7812be..1875981c15 100644 --- a/java/com/google/gerrit/server/restapi/change/TestSubmitRule.java +++ b/java/com/google/gerrit/server/restapi/change/TestSubmitRule.java @@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.SubmitRecord; import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.common.TestSubmitRuleInfo; @@ -44,6 +45,8 @@ import java.util.List; import org.kohsuke.args4j.Option; public class TestSubmitRule implements RestModifyView { + private static final FluentLogger logger = FluentLogger.forEnclosingClass(); + private final Provider db; private final ChangeData.Factory changeDataFactory; private final RulesCache rules; @@ -88,7 +91,7 @@ public class TestSubmitRule implements RestModifyView Date: Thu, 18 Jun 2020 15:53:30 +0900 Subject: [PATCH 4/6] TestSubmitType: Enable logErrors when debug logging is enabled Change-Id: Ib46367271496bb35e702b6400e988b3095c190f1 --- .../google/gerrit/server/restapi/change/TestSubmitType.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/com/google/gerrit/server/restapi/change/TestSubmitType.java b/java/com/google/gerrit/server/restapi/change/TestSubmitType.java index c1be1cea00..e67a319bac 100644 --- a/java/com/google/gerrit/server/restapi/change/TestSubmitType.java +++ b/java/com/google/gerrit/server/restapi/change/TestSubmitType.java @@ -15,6 +15,7 @@ package com.google.gerrit.server.restapi.change; import com.google.common.base.MoreObjects; +import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.data.SubmitTypeRecord; import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.common.TestSubmitRuleInput; @@ -35,6 +36,8 @@ import com.google.inject.Provider; import org.kohsuke.args4j.Option; public class TestSubmitType implements RestModifyView { + private static final FluentLogger logger = FluentLogger.forEnclosingClass(); + private final Provider db; private final ChangeData.Factory changeDataFactory; private final RulesCache rules; @@ -68,7 +71,7 @@ public class TestSubmitType implements RestModifyView Date: Thu, 18 Jun 2020 08:26:48 +0200 Subject: [PATCH 5/6] config-project-config.txt: reformat submit-section This section had a strange format that made it hard to recognize the enumeration of the various submit options. Refactor it so that it's aligned with the other sections. Change-Id: I69d6dc081680eadf92ddbfcac881367c1367d4bd --- Documentation/config-project-config.txt | 40 ++++++++++++++----------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/Documentation/config-project-config.txt b/Documentation/config-project-config.txt index 71af331341..22d8a0dbf8 100644 --- a/Documentation/config-project-config.txt +++ b/Documentation/config-project-config.txt @@ -316,26 +316,32 @@ the parent project. The submit section includes configuration of project-specific submit settings: -- 'mergeContent': Defines whether to automatically merge changes. Valid values -are 'true', 'false', or 'INHERIT'. Default is 'INHERIT'. +[[submit.mergeContent]]submit.mergeContent:: ++ +Defines whether to automatically merge changes. Valid values are 'true', 'false', or 'INHERIT'. +Default is 'INHERIT'. -- 'action': defines the link:#submit-type[submit type]. Valid -values are 'fast forward only', 'merge if necessary', 'rebase if necessary', -'rebase always', 'merge always' and 'cherry pick'. The default is 'merge if necessary'. +[[submit.action]]submit.action:: ++ +Defines the link:#submit-type[submit type]. Valid values are 'fast forward only', +'merge if necessary', 'rebase if necessary', 'rebase always', 'merge always' and 'cherry pick'. +The default is 'merge if necessary'. -- 'matchAuthorToCommitterDate': Defines whether to the author date will be changed to match the -submitter date upon submit, so that git log shows when the change was submitted instead of when the -author last committed. Valid values are 'true', 'false', or 'INHERIT'. The default is 'INHERIT'. -This option only takes effect in submit strategies which already modify the commit, i.e. -Cherry Pick, Rebase Always, and (perhaps) Rebase If Necessary. - -- 'rejectEmptyCommit': Defines whether empty commits should be rejected when a change is merged. -Changes might not seem empty at first but when attempting to merge, rebasing can lead to an empty -commit. If this option is set to 'true' the merge would fail. An empty commit is still allowed as -the initial commit on a branch. - -Merge strategy +[[submit.matchAuthorToCommitterDate]]submit.matchAuthorToCommitterDate:: ++ +Defines whether the author date will be changed to match the submitter date upon submit, so that +git log shows when the change was submitted instead of when the author last committed. Valid +values are 'true', 'false', or 'INHERIT'. The default is 'INHERIT'. This option only takes effect +in submit strategies which already modify the commit, i.e. Cherry Pick, Rebase Always, and +(when rebase is necessary) Rebase If Necessary. +[[submit.rejectEmptyCommit]]submit.rejectEmptyCommit:: ++ +Defines whether empty commits should be rejected when a change is merged. When using +link:#submit.action[submit action] Cherry Pick, Rebase If Necessary or Rebase Always changes may +become empty upon submit, since the rebase|cherry-pick can lead to an empty commit. If this option +is set to 'true' the merge would fail in such a case. An empty commit is still allowed as the +initial commit on a branch. [[access-section]] === Access section From e200656c90d8c0284d7cfc6cd61d19f188c6e4e3 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 18 Jun 2020 20:02:03 +0900 Subject: [PATCH 6/6] PrologOptions: Enable error logging for dryrun options when debug is enabled Change-Id: Ib2e2ef1e72f6f9f655bcad4a73c5aae9c413a2af --- java/com/google/gerrit/server/rules/PrologOptions.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/com/google/gerrit/server/rules/PrologOptions.java b/java/com/google/gerrit/server/rules/PrologOptions.java index da9b3aba64..a176f0429e 100644 --- a/java/com/google/gerrit/server/rules/PrologOptions.java +++ b/java/com/google/gerrit/server/rules/PrologOptions.java @@ -15,18 +15,21 @@ package com.google.gerrit.server.rules; import com.google.auto.value.AutoValue; +import com.google.common.flogger.FluentLogger; import com.google.gerrit.common.Nullable; import java.util.Optional; @AutoValue public abstract class PrologOptions { + private static final FluentLogger logger = FluentLogger.forEnclosingClass(); + public static PrologOptions defaultOptions() { return new AutoValue_PrologOptions.Builder().logErrors(true).skipFilters(false).build(); } public static PrologOptions dryRunOptions(String ruleToTest, boolean skipFilters) { return new AutoValue_PrologOptions.Builder() - .logErrors(false) + .logErrors(logger.atFine().isEnabled()) .skipFilters(skipFilters) .rule(ruleToTest) .build();