668 Commits

Author SHA1 Message Date
Wyatt Allen
0aeceaa5be Revert "Add a User Preference to Receive only Plaintext Emails"
This reverts commit 39777363a63c603cfa68ca52d2f3c99eb04f2f46.

Reason for revert: the frontend part of this change doesn't work.

Change-Id: I53138e939a1b98578787457e48743fdc8abf658c
2017-02-15 00:49:11 +00:00
David Pursehouse
ab879094c0 Merge "Add a User Preference to Receive only Plaintext Emails" 2017-02-14 23:18:27 +00:00
Patrick Hiesel
39777363a6 Add a User Preference to Receive only Plaintext Emails
This adds a user preference such that we only send plaintext emails to
this user. It also adds docs and tests.

For the user, this comes at the cost of not being in the same email
thread as the users who receive HTML emails. We decided to send out
plaintext emails on a one-by-one basis instead of making one thread (as
we do with HTML) as this would just create more confusion.

When admins enable inbound email for Gerrit, the aforementioned caveat
isn't a problem anymore as users would email Gerrit anyway instead of
using a notification email as messaging thread.

Change-Id: I3d0fc920c9d81e1a7b707ae5f3f4600a62b8a93b
2017-02-14 15:32:52 +01:00
Changcheng Xiao
81c4809ac3 Store the number of unresolved comments in change index
When changes are queried, we want to return the number of unresolved
comments with each change. This number should be pre-counted rather than
loading all the comments and counting each time.

We also add new search operators, which allow user to query by
"has:unresolved" and "unresolved:<RELATION><NUMBER>".

The 'unresolvedCommentCount' field of 'ChangeData' will be null if
'lazyLoad' is false.

Change-Id: I97c6aeb47db48f56f94c5d184dfa36c8d7868cc8
2017-02-13 11:31:49 +01:00
Edwin Kempin
e1f9dd1120 AccountApi: Add methods to get emails and delete email
Also add a test for email deletion and add asserts for the addEmail()
test.

Bug: Issue 5385
Change-Id: I3e192638fdaac58d0cdaa535430bb968d7d32abb
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-02-08 13:42:46 +01:00
Dave Borowitz
292fa154c1 Format all Java files with google-java-format
Having a standard tool for formatting saves reviewers' valuable time.
google-java-format is Google's standard formatter and is somewhat
inspired by gofmt[1]. This commit formats everything using
google-java-format version 1.2.

The downside of this one-off formatting is breaking blame. This can be
somewhat hacked around with a tool like git-hyper-blame[2], but it's
definitely not optimal until/unless this kind of feature makes its way
to git core.

Not in this change:
* Tool support, e.g. Eclipse. The command must be run manually [3].
* Documentation of best practice, e.g. new 100-column default.

[1] https://talks.golang.org/2015/gofmt-en.slide#3
[2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html
[3] git ls-files | grep java$ | xargs google-java-format -i

Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2017-02-07 10:04:39 +09:00
Gustaf Lundh
1386d59c01 Add REST endpoint for commit included in
+ API and acceptance tests for {Change,Commit}IncludedIn

Change-Id: I5000cc90b8f0457e2b7594e86e9165f1a6cb8aa5
2017-02-01 11:12:33 +09:00
Kasper Nilsson
eb64a0ae1e Add API portion of account status
Adds PutStatus.java and GetStatus.java for modification of the logged-in
user's status field.

Feature: Issue 4394
Change-Id: Id13241dcd98c46101cea2f2337c1fb731d0465a0
2017-01-31 10:58:03 -08:00
David Pursehouse
c4f1aec9c2 Remove redundant 'final' and 'public' modifiers
Change-Id: I7567e42f1d8203037a2d5596acce0fc09475714b
2017-01-28 21:39:02 +09:00
Changcheng Xiao
402c249b4a Account REST API: Add a new endpoint to delete external IDs
The REST endpoint is added as:
'POST /accounts/{account-id}/external.ids:delete'
The target external ids must be provided in the request body.

Change-Id: Ieef322d6bddc1f3659536081b3f3514474b7162a
2017-01-27 10:12:32 +01:00
Alice Kober-Sotzek
5dd17b647e Add Java API for change edits and use it in tests
For some reason, a Java API for change edits didn't exist previously
even though a detailed REST API has been available. Because of that,
tests needed to use internal classes when they interacted with change
edits. Using internal classes is fragile and impedes refactorings.
That's why we should avoid it.

If possible, the structure and behavior of the tests is kept. Some of
them might and should be improved but that's beyond the scope of this
change. Some of the tests are adapted a bit because the internal
classes allow change edits to be created for previous patch sets
which isn't possible when using the REST API (and hence the Java API).

As modifications to the mentioned internal classes are necessary to
properly implement the 'Apply fix' feature of robot comments, it is
crucial that none of the tests use the internal classes directly.
In addition, the tests which will be added for the 'Apply fix' feature
will also need to modify and query change edits, which will be much
easier with the Java API.

Change-Id: I6b455541d1bc1b7a05b5f0507911181b0451829a
2017-01-24 15:16:20 +01:00
David Ostrovsky
fdbfcad77d Remove Buck based build
Bug: Issue 5302
Change-Id: I6e860446ef30ff0ad1c7c49fc0e39d39d921820b
2017-01-23 12:44:58 +00:00
Dave Borowitz
484da493b3 Prefer subtypes of Multimap
Guava team recommends using the subinterfaces of Multimap, for the
same reasons they recommend using Set and List rather than Collection:
it documents expectations about ordering, uniqueness, and behavior of
equals. Do this across the board in Gerrit.

Mostly this is straightforward and I tried to exactly match existing
behavior where possible. However, there were a few wrinkles, where
different callers passed different subtypes to the same method.

The main one is arguments to ParameterParser#parse and
splitQueryString, where some callers used SetMultimaps (perhaps
semi-intentionally, or perhaps misunderstanding the nature of
HashMultimap). For the purposes of parameter parsing, a ListMultimap
makes more sense, because it preserves argument order and repetition.

Another instance is a couple places in ReceiveCommits and downstream
where there were SetMultimap<?, Ref>. Since Refs do not implement
equals, this is effectively the same thing as a ListMultimap, and
changing the interface no longer misleads readers into thinking there
might be some deduplication happening.

Finally, this change includes a breaking API change to the return
type of ExternalIncludedIn#getIncludedIn.

Change-Id: I5f1d15e27a32e534a6aaefe204e7a31815f4c8d7
2017-01-18 10:36:38 +09:00
Dave Borowitz
e5c5953205 AccountExternalIdInfo: Implement hashCode alongside equals
Change-Id: I5f88bd25dde7a9fb8d429a2ef4fad2f104de223a
2017-01-18 10:25:58 +09:00
David Pursehouse
38dd926ff8 Merge "Account REST API: adjust the deletable condition of external ids" 2017-01-17 08:58:42 +00:00
Changcheng Xiao
a2ffc209a4 Account REST API: adjust the deletable condition of external ids
Set the 'canDelete' field of external ids to be true if the external id
for the last login is null.

This is different from the old remote JSON service implementation, but it
seems reasonable because an external id should be deletable if the external
id is not a 'SCHEME_USERNAME' and it's not used to login.

And this change will make it much easier for us to test the get/delete
external ids REST API.

Change-Id: I0ab347bddf782b20a3be1826279df5a1ba88c5df
2017-01-17 08:35:54 +01:00
Edwin Kempin
67810cf171 Fix error message when --query and --query2 are both used on GET /groups/
--query and --query2 on GET /groups/ are mutually exclusive. Using
both of these options at the same time already failed because the
QueryGroups REST endpoint was always returned when --query2 was
specified and QueryGroups was rejecting --query with:

  "--query" is not a valid option

Change-Id: I89aa4ea8c7f5ed8e354e0cf42635b96aba7ed93e
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-16 17:06:13 +01:00
Edwin Kempin
5f8c383ab7 Support to control notifications when creating changes through REST
Change-Id: I0792c38f429459ce2e2f74fef2dc0b962188f451
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-13 11:48:48 +01:00
Changcheng Xiao
0748e7441d Add REST endpoint to get account external IDs
Add a new endpoint /accounts/{id}/external.ids which will return a
list of the external IDs for the given account. It is only allowed
to get this list for a user's own account.

To determine whether or not the user can delete an external ID, we
need to know if that ID was used to log into the current session.

The WebSession is not available outside of gerrit-httpd, so pass the
external ID through a property on the current user.

Change-Id: Iab7ef2ffa06c3a8d9f22472308051b4b73668f82
2017-01-12 16:14:12 +01:00
David Pursehouse
e93b40b3e1 Merge changes from topic 'group-index'
* changes:
  Index groups that are created during init
  Implement group index for ElasticSearch
  Add REST endpoint to reindex a single group
  Support default query for groups
  Add query operator that matches groups that are visible to all users
  Add group query operator to match groups by owner
  Add group query operator to match groups by description
  Support querying groups by name and name part
  Set '_more_groups' on last group of query result
  Add tests for group index
  Groups API: Add query methods
  Support arbitrary group queries via REST
  Add new optional interface for REST collections to get request params
  Add GroupQueryProcessor
  IsVisibleToPredicate: Move describe method into base class
  Index group on creation and whenever a group is evicted from cache
  Initial implementation of group index in Lucene
  Add initial GroupQueryBuilder and define key predicate for group index
  Add schema and index definitions for groups index
2017-01-12 03:56:49 +00:00
Edwin Kempin
d77a98f909 Accounts: Make JavaDoc consistent
Change-Id: I0f0316b8f66b86ef55c91fc39412ec297142a1e5
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 13:09:52 +01:00
Edwin Kempin
4550a256cb Add REST endpoint to reindex a single group
This may become handy to fix single groups that are stale in the
index.

Change-Id: Iab3711f343fe1da9bba4979792edc83c76d75a09
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 11:59:27 +01:00
Edwin Kempin
a45b072688 Support querying groups by name and name part
This adds two query operators for group queries:

1. name:
   Exact match on the group name (case-insensitive)
2. inname:
   Prefix match on a group name part (case-insensitive)

Change-Id: Iedec2574690881470ba7f0ff7cd12263e466352f
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 11:59:26 +01:00
Edwin Kempin
fadf363ef0 Set '_more_groups' on last group of query result
If the number of groups matching the query exceeds the limit the
last group has a '_more_groups: true' JSON field set.

Change-Id: I6f1fcda58813e2c7b5dc788d88b989c377afec7e
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 11:59:26 +01:00
Edwin Kempin
03ca929631 Groups API: Add query methods
Change-Id: I8a47f281b1311675781ec520e278a5144d5b42c9
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 11:59:20 +01:00
Edwin Kempin
d819316d42 Add new optional interface for REST collections to get request params
REST collections decide which REST endpoint is used to handle GET
requests on the collection by returning the implementation of this
REST endpoint from the list() method. Sometimes depending on the
presence of certain URL parameters it makes sense to let different
REST endpoints handle the listing. For this the REST collection needs
to know which URL parameters were specified. By implementing the new
NeedsParams interface the REST collection can now get to know the URL
parameters.

Change-Id: I78a7b7a26324c63bc7ee24e7f0928f907146981d
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 11:56:03 +01:00
David Pursehouse
1d3b9b5072 Merge "Remove unneeded exception declarations on methods in NotImplemented" 2017-01-06 01:38:06 +00:00
Dave Borowitz
08cbca72e5 Merge "Add api portion of resolvable comments" 2017-01-05 21:19:01 +00:00
Edwin Kempin
5b1538b710 Remove unneeded exception declarations on methods in NotImplemented
Change-Id: I66605f6022107ccea9e9759b37d2ce7f60725f45
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-05 16:27:33 +01:00
Kasper Nilsson
7ec3036ab1 Add api portion of resolvable comments
With this change, the unresolved field of a comment is now set by the
value supplied in the request body. If no value is supplied, the value
of the parent is used, and if no parent exists then comments default to
unresolved=false.

Change-Id: I4d2e16e42a78473b78b4e5b044687df4c5554963
2017-01-04 17:00:17 -08:00
Changcheng Xiao
2fcae69087 Support deleting vote on a revision
Right now deleting a vote is done by:
'DELETE /changes/{change-id}/reviewers/{account-id}/votes/{label-id}'
A new REST endpoint is added as:
'DELETE /changes/{change-id}/revisions/{revision-id}/reviewers/{account-id}/votes/{label-id}'

This new endpoint can help prevent deleting the vote (with same label)
from a newer patch set by mistake.

'List Revision Reviewers' and 'List Revision Votes' endpoints are also
added as by-products. All of the three endpoints are limited on current
revision.

Change-Id: I85fac04db986c2133cd39d2d06648d1dad8c3b4c
2017-01-04 19:13:24 +01:00
Changcheng Xiao
9b04c04a41 Add a REST API endpoint to support retrieve the robot comment list of a change.
Bug: Issue 5053
Change-Id: I4595ae584a6c427d753c4ad9d9a278803ff3a180
2016-12-28 13:09:59 +01:00
Paladox
1e55a382d6 Update codemirror to 5.22.0
Highlights include:
 - New themes duotone-light and duotone-dark
 - Various small fixes to language modes

Change-Id: I632cc2dd3815767293ea9638b0551f7a98f330b2
2016-12-22 23:40:25 -04:00
Dave Borowitz
194d5095f8 Merge "Add Setting to expand diffs inline or open diff view (backend)" 2016-12-20 01:48:17 +00:00
Alice Kober-Sotzek
110f60f082 Make the file path for the replacement of a robot comment explicit
Up to now, the file path was implicitly limited to the file on which
the robot comment was placed. This restriction will be relaxed in the
future. In order to not break systems which use the fix suggestions at
that (later) point in time, the mandatory field 'path' is introduced
with this change.

Change-Id: I73875b97bf844dee927720765046161bbd888c02
2016-12-19 16:45:26 +01:00
Becky Siegel
e450a31f98 Add Setting to expand diffs inline or open diff view (backend)
Adds a general preference setting for expanding diff views inline from
the change view rather than opening the diff view as a new page. Also
updates documentation that was missed prior for change table columns.

Feature: Issue 5115
Change-Id: I0055961e7b79d74afc3a85de441b53a38f8de4a3
2016-12-16 15:48:35 -08:00
Kasper Nilsson
c101b42cc3 Implement NoteDB portion of resolvablility
The server doesn't need to handle resolvedness of a thread; the plan is
for it to be an entirely client-side implementation. Whatever value the
most recent comment has for 'unresolved' is the value that will
determine whether the thread is resolved, but each individual comment
will still have that value populated so as to keep a log of when it was
changed and who it was changed by.

Change-Id: If45057935f4f30bb6babbe5e80223b8da3fa694f
2016-12-15 21:08:55 +00:00
David Pursehouse
58b8d76204 Add support for parent revisions weblinks provided by plugins
Support for parent weblinks was removed in change I8508dcaf3. This is a
regression for some users who rely on that information being present.

On the other hand, not all users want to have these links going to the
same external service as the patch set revision links, so we can't just
add it back as it was.

Instead, add a new plugin web link interface for the parent revisions.

If a plugin provides an implementation of ParentWebLink, the links will
be displayed beside the parent revisions on the change screen.

For the built-in gitweb support, provide the parent links using the same
template as the patch set links, so they will always appear when the
gitweb config defines the 'revision' setting.

Bug: Issue 4908
Change-Id: Icdf0f997f939128717ee4edc2c147a26eeaebad6
2016-12-09 11:51:01 +09:00
David Pursehouse
d0a1e11c72 Merge changes I529bfa5e,I59aa42d8
* changes:
  Move custom Truth subjects to gerrit-test-util
  Add unit tests for Comment.Range#isValid
2016-12-09 01:21:16 +00:00
David Pursehouse
467aecb7d0 Add REST API endpoint to delete multiple tags
Change-Id: I1a1146aaf1b72ad369390cd916fbe62cf4683467
2016-12-08 16:04:19 +00:00
David Pursehouse
b97862ed76 Merge changes I1547893a,I40f0a2ca
* changes:
  Add tests for the delete tag REST API
  Add REST API endpoint to delete a tag
2016-12-08 16:02:29 +00:00
Dave Borowitz
d94fa83439 Merge changes Id112b701,Ia33389c5
* changes:
  Allow to explicitly specify whom to notify on a change update
  Test that watchers are notified for new changes only if notify is ALL
2016-12-08 15:04:18 +00:00
David Pursehouse
e113216219 Add REST API endpoint to delete a tag
Also-by: Paladox none <thomasmulhall410@yahoo.com>
Change-Id: I40f0a2ca40a615aa2bf757171aaf393afd9eb8ad
2016-12-08 14:23:44 +00:00
Alice Kober-Sotzek
bc8186ad79 Add unit tests for Comment.Range#isValid
In order to use the RangeSubject within gerrit-extension-api as well
as gerrit-acceptance-tests, a new Bazel/Buck package is introduced.
The purpose of this package is to bundle test helper classes which are
shared by different packages.

Change-Id: I59aa42d89c06f4de60a2a05d41a72653eba268de
2016-12-08 11:21:48 +01:00
Stefan Beller
e1b2ad34bc PreviewSubmit: fix generation of compressed tar entries
For the PreviewSubmit call plain tar as well as zip works fine, but
formats like tbz2, tgz and txz are broken.

This bug comes from not knowing the size of the bundles before writing
them, such that it was assumed to 0. Plain tar as well as zip worked
just fine as the tools ignored the wrong size.

Fix the bug by creating the bundle in memory and then correctly use
JGits ArchiveCommand for different formats.

To demonstrate the bug is fixed, add a test that just lists files
in the return of a call of preview submit call with tgz format
specificed.

By this change a bundle cannot be streamed any more, but needs to
be kept in memory. As bundles may become large, introduce a new
config option to set an upper bound for a bundle that is build up
in memory.

A slightly unrelated change is the wrapping of the
ArchiveOutputStream in a try-with-resource block as it implements
AutoCloseable. (Before it was not closed explicitly but just
finish()ed.)

Change-Id: I587c0e81ed79be94d7abf2a19ad2086c005933d9
Signed-off-by: Stefan Beller <sbeller@google.com>
2016-12-07 10:04:31 -08:00
ekempin
6b1cd81f90 Merge changes I69cf3fc4,Ib6e9e942
* changes:
  Add support for suggested fixes of robot comments
  Split long method into smaller ones
2016-12-07 15:01:27 +00:00
David Pursehouse
34321931e8 Merge "Remove test prefix from test methods"
* submodules:
* Update plugins/replication from branch 'master'
  - Remove test prefix from test methods in replication plugin
    
    We previously used 'test' to prefix tests but have decided to stop this.
    This change removes the prefix from all test code.
    
    Change-Id: I42e6191ece7872f4647e425e3ca0acf8c6452412
2016-12-07 12:48:37 +00:00
Alice Kober-Sotzek
bcd275eb7f Add support for suggested fixes of robot comments
With this change, suggestions for fixes can be provided with a robot
comment. At the moment, those suggestions are implicitly limited to the
file to which the robot comment was attached.

Change-Id: I69cf3fc4bdc66d69a5831b1e6c78937b8e945a72
2016-12-07 13:36:30 +01:00
David Ostrovsky
fa18907d7f Bazel: Reformat build files
Reformat the Bazel build files with the buildifier tool [1].

The style is different for Bazel files. Most notably, indentation level
is 4 spaces instead of 2, and " is used instead of '.

[1] https://github.com/bazelbuild/buildifier

Change-Id: I95c0c6f11b6d76572797853b4ebb5cee5ebd3c98
2016-12-07 11:33:07 +00:00
Patrick Hiesel
a02a5c01e9 Remove test prefix from test methods
We previously used 'test' to prefix tests but have decided to stop this.
This change removes the prefix from all test code.

Change-Id: I229a36751adc6a87fbae8d6f373671e141529496
2016-12-06 10:36:42 +01:00