2991 Commits

Author SHA1 Message Date
Dave Borowitz
c079ccd23a Move CommitSubject and ObjectIdSubject to git.testing package
They belong there right next to the JGit PushResultSubject, they were
just put in the wrong place initially.

Change-Id: Iaef009136888c813f1bd20b7988e4f59259e860e
2019-02-22 09:32:55 -08:00
Patrick Hiesel
8fffeff0fa Rename 'comments' to 'entities' in generalized RevisionNote
Change-Id: I9c6300a0cc1f68d411927c72becccf7b98c7163a
2019-02-22 08:32:37 +01:00
Patrick Hiesel
5f8ba3d5c8 Merge "Make more of AbstractChangeNotes public for checks plugin" 2019-02-22 07:30:37 +00:00
Patrick Hiesel
b4fe84829d Merge "Allow RevisionNotes to be any type, not just Comments" 2019-02-22 07:30:29 +00:00
Patrick Hiesel
44d2a1fc31 Merge "Make RevisionNote public for checks plugin" 2019-02-22 07:29:30 +00:00
Patrick Hiesel
8074e7c2a0 Merge "Add PLUGIN_CHECKS as an option for @UsedAt" 2019-02-22 07:29:10 +00:00
Dave Borowitz
54e407e051 Make more of AbstractChangeNotes public for checks plugin
Change-Id: Ie5758cd9d585d61b46ac3512f67b20755d6e93cc
2019-02-22 11:13:57 +09:00
Dave Borowitz
399134f939 Allow RevisionNotes to be any type, not just Comments
Change-Id: Iab28dd2a5950f2f6714bec7a8b7f93b0642e91b6
2019-02-22 11:13:52 +09:00
Dave Borowitz
1f9e76eaca Make RevisionNote public for checks plugin
Change-Id: Id5870f6c9c8bd98f7a2ce94443c7c7e8fa52532e
2019-02-21 16:15:57 -08:00
Dave Borowitz
f7077c8745 Add PLUGIN_CHECKS as an option for @UsedAt
Change-Id: I09a0629f77d8543c4502722560a3965d4a066d5a
2019-02-21 14:07:44 -08:00
Dave Borowitz
5b33f03e5e ChangeQueryProcessor: Don't rescan plugins when sizing list
DynamicMap#plugins() creates a new TreeSet on every invocation. We were
just doing this to presize an ArrayList, which makes it seem like we
care about reducing allocations, but was probably actually increasing
allocations. Fortunately, we can just presize using the multimap we
already have. This also allows us to remove a redundant instance field.

Change-Id: Ie5998add61d4848e184a37f4f237da132802a00f
2019-02-21 11:01:57 -08:00
Dave Borowitz
0b1e2c7256 ChangeQueryProcessor: Make attributeFactoriesByPlugin immutable
This emphasizes to the reader that this map is not supposed to be
mutated after construction time.

It is tempting to store Extensions instead of constructing our own map.
However, repeatedly calling Extensions#get() could cause performance
problems. Leave a comment about why we aren't doing this.

Change-Id: I466b2c17ea1e1b8a9304c97a579cdd3184e033fc
2019-02-21 11:01:57 -08:00
Dave Borowitz
a3c2503433 ChangeQueryProcessor: Inline setupAttributeFactories
This method was definitely not safe to call multiple times, since it
would add duplicate entries to the mutable map stored in the instance
field. The map should really only be initialized once, during
construction.

Change-Id: I6cbb792adb6ae9dbec70df3f45586dc518faf913
2019-02-21 11:01:57 -08:00
Dave Borowitz
f72cce702f ChangeQueryProcessor: Log when plugin attributes can't be loaded
Debugging production problems is much more difficult when exceptions are
completely swallowed. At the same time, if a plugin fails on all inputs,
logging one entry for every change in a large query result set would be
terrible as well. Split the difference and log once a minute; Flogger
makes this very easy. We can always decide to come back later and
complexify it by logging e.g. once per plugin or per factory, but this
is dead simple and pretty quiet.

Change-Id: If512583aef10e48c745660c42f021837caeb2994
2019-02-21 11:01:57 -08:00
Dave Borowitz
737fb08e06 AbstractDaemonTest: Add method for temporarily installing plugin
A plugin is really just a name plus one or more module classes. We
already have the TestServerPlugin magic which is used by
LightweightPluginDaemonTest, so reuse that. The difference is that the
use case for this new method is for testing the plugin plumbing itself,
not testing a specific real-world plugin.

Change-Id: I3ca4eda806519ad9bdd653e0b5f897e69ed119af
2019-02-21 07:02:00 -08:00
Dave Borowitz
d4ae9752ea RefNames: Make parseShardedUuidFromRefPart public for plugins
Change-Id: I2ddb5cd7681cca4d7485b16c64f9ff4631fab2ee
2019-02-21 07:02:00 -08:00
Dave Borowitz
961dff6ec6 AbstractDaemonTest: Return default config from resetProjects
Subclasses that override resetProjects may want to add to the default
config, rather than recreating it all from scratch. Previously, the
default config was never exposed to subclasses. Now, they can get it via
super.resetProjects() (or not, as current implementors all prefer).

Change-Id: If116e5fce9e0fe0f826b66c1f84774660f20dec7
2019-02-21 07:02:00 -08:00
Dave Borowitz
4fe329670f Add Truth subject for JGit RevCommits
Change-Id: Iae208db9202a82fda45f650831786562e36a3a4f
2019-02-21 07:02:00 -08:00
Dave Borowitz
2ce268141a RetryHelper: Add action type for use by plugins
Allowing plugins to specify custom action types may be feasible, but at
a minimum requires changing the type of the metrics.

Change-Id: Ieb659c8e86f59085e57dbcb134e3582039025223
2019-02-19 18:33:54 -08:00
Dave Borowitz
63af804e07 RefNames: Make shardUuid public, for use in plugins
Change-Id: I0b12e274b0a1b3aec43d6645bd1f22cd8b63e825
2019-02-19 18:33:54 -08:00
Dave Borowitz
d57ee77028 Move UsedAt to common package
Change-Id: Iaa4dc1e945da07e2065a72be38e528c71b19a235
2019-02-19 18:33:54 -08:00
Dave Borowitz
81bf64e4b7 UsedAt: Remove @BindingAnnotation
This annotation is not intended to be used as a qualifier for Guice
bindings.

Change-Id: Ib101287eb520189edaaae03f0af137804543d1fc
2019-02-19 18:33:54 -08:00
Dave Borowitz
c2138c6a74 Add Truth subject for ObjectIds
Change-Id: I48fcc4796aa45bb8f2545e8efd8fafe2390cef99
2019-02-19 18:33:54 -08:00
Dave Borowitz
b24a46e7a5 Add missing license headers
Found with:
  for f in $(find [a-z]* -name \*.java); do echo "$f $(head -n1 $f)"; done | grep -v '// Copyright'

The remaining classes not touched in this file all have nonstandard
license headers, because they were copied from other projects. Or
they're plugins, which should be fixed separately.

Copyright dates are taken from original creation of the file.

Change-Id: I3be07ac46fd999f07c230eacbf4508f39fda1b77
2019-02-19 18:33:54 -08:00
David Pursehouse
b8969585ec Merge branch 'stable-2.16'
* stable-2.16:
  Fix missing `</section>` in gr-settings-view
  Suggest --no-edit when Change-Id is missing
  PG: Assume weblinks have correct direct or relative urls
  PG: Make commitlink selection configurable and consistent
  Add config gerrit.primaryWeblinkName
  gerrit.sh: Improve error message when JRE cannot be found
  PrologEnvironment#setPredicate: Reduce log level to DEBUG
  ElasticContainer: Bump V7_0 test server to 7.0.0-beta1

Change-Id: I8bef4ae02e935809de6d7abf59e1a8de6800432c
2019-02-19 10:25:32 +09:00
David Pursehouse
a172ef1aa3 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  ElasticContainer: Bump V7_0 test server to 7.0.0-beta1

Change-Id: I0f499e2dbc8fb44ee2f85a6faef4be3deec1315b
2019-02-19 08:24:52 +09:00
Orgad Shaneh
25daae72a1 Suggest --no-edit when Change-Id is missing
There is no reason to start the editor just for adding
Change-Id.

Change-Id: I2e3b093ab123d4a9d55736e6c2ad83a07a194f53
2019-02-18 13:58:04 +00:00
David Pursehouse
db46a86e38 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  gerrit.sh: Improve error message when JRE cannot be found
  PrologEnvironment#setPredicate: Reduce log level to DEBUG

Change-Id: I26703bd42f91a96dc985a2de8e90f93be78bdd63
2019-02-18 21:07:53 +09:00
David Pursehouse
10c1299c83 Merge changes If3aaa629,I01deaca3 into stable-2.16
* changes:
  PG: Make commitlink selection configurable and consistent
  Add config gerrit.primaryWeblinkName
2019-02-18 09:08:00 +00:00
Sven Selberg
e63e92d89e Add config gerrit.primaryWeblinkName
Add gerrit.primaryWeblinkName to ServerInfo.
Lets the UI know which is the preferred weblink in instances were
only one weblink can be used, for example in inline links.

Change-Id: I01deaca3418d5c0486e3f5ebabf10827d47c3631
2019-02-18 09:01:54 +00:00
Patrick Hiesel
707e61a75a Disallow marking merged/abandoned changes private
We want to improve the UX of private changes by limiting the number of
merged private changes. As a first step, we stop allowing users to mark
merged (or abandoned) changes private.

A subsequent commit will auto-publish private changes on submission and
include a UI dialog that tells the user about this process.

Change-Id: Ia4039099b5b23b9db6c88183be51687168e59580
2019-02-16 15:28:29 +09:00
David Pursehouse
7f5d6edab2 Merge branch 'stable-2.16'
* stable-2.16:
  Move *Op classes from c.g.g.s.restapi.change to c.g.g.s.change

Change-Id: Iae38283f95d4d7696236f184411005fb0878cd65
2019-02-16 15:24:14 +09:00
Changcheng Xiao
3b817164e3 PatchSetInserter: allow to set "sendEmail" bit
With this new "sendEmail" bit, we will have more control
for whether emails are going to be sent out after a new
patch set is added. This is useful for avoiding duplicate
emails, e.g merge (already have an email to notify a change
is merged, no need to have another email to say a new patch
set is uploaded).

Change-Id: I43c5d7c6560316d5a6034dc8e711f7e87b7af932
2019-02-15 17:43:57 +01:00
David Pursehouse
9b728841fa Move *Op classes from c.g.g.s.restapi.change to c.g.g.s.change
The majority of these classes are already in the c.g.g.s.change package.

Change-Id: Ic62b9f05443e2cd5167bab28eed789ad9669618f
2019-02-15 09:47:07 +09:00
David Pursehouse
bd00083e48 Merge branch 'stable-2.16'
* stable-2.16:
  PrologEnvironment: Add logging of reduction limits

Change-Id: I196585f29742b8b26f29187a76f00e2d98ca9f85
2019-02-14 22:10:17 +09:00
David Pursehouse
ccf646765e Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  PrologEnvironment: Add logging of reduction limits

Change-Id: Ic2b91320fadc837c91b578db27d7d46b15eb0f9d
2019-02-14 19:49:53 +09:00
David Pursehouse
4c58e1031f Change: Add helper methods to check change state
To check a change's state the caller currently has to call getState()
and then do a comparison on the enum value.

To make this easier, introduce new methods on Change:

- isNew
- isMerged
- isAbandoned
- isClosed

Note that we don't add "isOpen" since there are no longer multiple
states that could be considered "open". Previously there were "new"
and "draft", but the draft workflow was removed.

Update callers to use the new methods.

Change-Id: Ic047f74b114e2277e66c878dace73ea8e0babab6
2019-02-14 13:48:51 +09:00
Dave Borowitz
14f1295319 FieldDef: Mark Getter#get as nullable
Change-Id: I6bb474883e2657aaa8effcc5600681426a484dcf
2019-02-13 08:07:28 -08:00
David Pursehouse
401e0b7eb1 Merge "Introduce sequential success commit messages" 2019-02-13 01:46:12 +00:00
David Pursehouse
b50973cc5c BatchUpdate: Fix 'invalid member type qualification' Javadoc warning
Change-Id: I2a4581ea2d817a273777f87ca7c5e4b4eeed1e43
2019-02-12 15:21:10 +09:00
David Pursehouse
f71771f40c DeleteReviewerByEmailOp: Remove unused input member
The input is unused since change If6f8a44f3.

Change-Id: I221e65eeabaa959b048a0517dfe7a8f253e21ba6
2019-02-12 15:21:00 +09:00
David Pursehouse
19a2fc7e5c Merge changes from topic "notify-resolver"
* changes:
  NotifyResolver: Use SetMultimap for accounts to notify
  Pass notification settings through BatchUpdate's Context
  Consistently pass NotifyResolver.Result instead of separate args
  Refactor NotifyUtil analogously to AccountResolver
  PostReview: Fix default notification settings, kind of
  Rename FakeEmailSenderSubject#notSent to didNotSend
  ChangeNotificationsIT: Consistently check sender queue is empty
  ChangeNotificationsIT: Don't trigger review after setting ready
2019-02-11 23:36:24 +00:00
Edwin Kempin
255d6a1709 Merge branch stable-2.16
* stable-2.16:
  ListProjects: Fix log statements

Change-Id: I5db5390e305e7b73bf9593999b8eaf8aa779bfa7
2019-02-11 17:30:43 +01:00
Edwin Kempin
d647534fe9 ListProjects: Fix log statements
With Flogger we must use '%s' as placeholder for parameters.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I834c84516b86b7bdcf800ab06748da30babd9a4f
2019-02-11 16:31:07 +01:00
Dave Borowitz
9f46d2e248 Resolve "self" even if inactive
Different systems may implement reactivation of accounts in different
ways. On googlesource.com, for example, accounts are automatically
reactivated on login through the web UI, but there are other codepaths
where reactivation may not happen automatically. Filtering out inactive
users when resolving "self" is therefore a regression: it would return
no results where prior to the AccountResolver rewrite it would have
returned results.

Fix the regression by resolving "self" even when inactive. I'm not
arguing that not auto-reactivating is the best behavior for
googlesource.com, just switching back to the old behavior of
AccountResolver.

The regressed behavior was especially confusing to debug because it
resulted in an exception message saying "Resolving account 'self'
requires login", even though the user was technically logged in.

Change-Id: I5aaf20eeb94ea6de268a96230d14ac85c4eb1863
2019-02-11 15:11:42 +01:00
Dave Borowitz
c3c55cfb4a Fix visibleto:self for anonymous users
This special case was erroneously removed in I7113aa7a. Add a regression
test that would have caught it.

I had thought it was safe to remove because AccountResolver now supports
"self. However, I didn't realize that the isSelf case worked for
anonymous users, while AccountResolver intentionally does not.

Change-Id: I393f74b37215b9a6296eedf1da6a935f1c9518a9
2019-02-08 15:13:33 -08:00
Dave Borowitz
eecebc44d6 NotifyResolver: Use SetMultimap for accounts to notify
An account ID should only appear once per RecipientType; allowing
duplicates of the same account ID with the same RecipientType doesn't
make sense. This shouldn't have any effect in practice, since these
accounts are converted to Sets within OutgoingEmail, but the code is
cleaner this way.

Change-Id: I677def1384151bfe52fa20e291864b260a9df3fb
2019-02-08 08:57:38 -08:00
Dave Borowitz
0312eb2315 Pass notification settings through BatchUpdate's Context
Previously, any notification settings that a BatchUpdateOp wanted to
respect in its postUpdate method needed to be resolved from the
corresponding REST API input and plumbed through the Op constructor so
they could be looked up as needed. Explicit can be good, but this verged
into the territory of _too_ explicit.

Instead, treat the notification settings as a property of the
BatchUpdate. This is somewhat magical, but in this case the magic is
justified. Conceptually, associating notification settings with the
BatchUpdate makes sense: there is a single set of notification settings
that is parsed at the top level from the input, and those settings
should apply to *all* emails sent as a result of that BatchUpdate,
regardless of the particulars of where they're sent from. Putting them
in the Context allows us to treat them as a per-BatchUpdate singleton.

We retain the ability to override the NotifyHandling enum on a
per-*change* basis, rather than a per-*op* basis, to account for the
reduced notifications from WIP changes.

Without this change, there's always the possibility of having multiple
Ops in the same BatchUpdate that send different emails with different
notification settings. For example, we had special code in PostReview
to ignore the notification settings embedded in the constituent
AddReviewerInputs of a ReviewInput. After this change, we still ignore
those settings (as the REST API docs specify), but we don't have to do
anything special to do so: we just set the NotifyResolver.Result on the
BatchUpdate to the one from the ReviewInput, completely ignoring the
AddReviewerInputs.

This change also has the effect of removing any logic around
notification settings from ReviewerAdder; all the notification logic is
in the caller. We still retain a separate mechanism for suppressing all
emails from ReviewerAdder, so that PostReview can send only a single
email. However, this is stored as a simple boolean, rather than passing
around a whole NotifyResolver.Result. It's still not completely ideal,
but considering everything else ReviewerAdder has to deal with, it's a
small win. Plus, simplifying ReviewerAdder will pave the way for
rewriting it in the near future.

One downside here is that any check to set NotifyHandling based on
properties of the change (e.g. the WIP bit) is racy, since the change
was read outside of the BatchUpdate. The risk and consequences of such a
race are low enough that the benefits described above still outweigh it.
(And it's not like it's the only such race, even though we do try to
keep them to a minimum.)

This change should have minimal behavior changes. One exception is that
moving around calls to NotifyResolver#resolve from the body of a try
block to the top level of a REST API handler might result in a 400/422
for invalid input in notify_details rather than logging and silently not
sending an email. Some endpoints already had this behavior, so making
the failure explicit and consistent is considered a feature.

Change-Id: If6f8a44f382f57b9cb10490f74c2b144e904ece8
2019-02-08 08:57:28 -08:00
Dave Borowitz
8e24b76649 Consistently pass NotifyResolver.Result instead of separate args
Change-Id: I457fa6cc45002a88440e33adf609b52f8610b9eb
2019-02-08 08:55:33 -08:00
Dave Borowitz
3949eea76e Refactor NotifyUtil analogously to AccountResolver
NotifyUtil#resolveAccounts was basically a wrapper around
AccountResolver. Give the class a new name, NotifyResolver, and have it
resolve inputs to a Result type. This Result type encapsulates both the
NotifyHandling enum and the ListMultimap that got passed around
everywhere. This has several significant advantages.

First, this pair of objects is used in many places, so cutting down two
arguments (including the unwieldy ListMultimap type) to one is a win on
its own. This change fixes some such methods, and the rest will be fixed
in future cleanups.

Second and more subtly, this change results in more explicit and less
error-prone behavior when a null notify field is passed in a REST API
object. Callers have to explicitly specify a non-null NotifyHandling
input to NotifyResolver#resolve, which typically means they have to do a
firstNonNull(input.notify, <some default>). It turns out that in the
REST API docs, there are several different defaults for the different
*Input types, including some that have different behavior for WIP/ready
changes. The documentation is structured per Input type, which means
it's always clear from the documentation what the default should be if
you have in front of you a FooInput. In other words, this pattern makes
it easier to inspect the code for correctness.

Change-Id: I609674d22b6a16b8fac32aeea1a57d293ee601d5
2019-02-08 08:55:27 -08:00