3060 Commits

Author SHA1 Message Date
Patrick Hiesel
5782cd6350 Merge "AsyncReceiveCommits: add metric for total push latency" 2019-03-14 15:41:24 +00:00
David Pursehouse
92175349d7 Merge branch 'stable-2.16'
* stable-2.16:
  Update download-commands plugin revision
  Upgrade google-java-format to 1.7

Change-Id: I6e959cde5b4790b469902245c3a2278883c65cad
2019-03-14 09:54:15 +09:00
David Pursehouse
7a519876e5 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Upgrade google-java-format to 1.7

Change-Id: Ia7383822ef59fb60bb5559956a065ae46b2e4f4a
2019-03-14 09:08:30 +09:00
Han-Wen Nienhuys
44b6e767fa AsyncReceiveCommits: add metric for total push latency
This metric reflects the user experience of pushing to Gerrit. Add a
new push type "NORMAL" to distinguish AUTOCLOSE from Gerrit serving
standard git push (which should be much faster).

Put the CREATED and REPLACED stats in the change counter together as
CREATED_REPLACED to mirror the latency metrics.

Change-Id: I1aae3bc0c0fe430086221503b8e529fa06967517
2019-03-13 18:21:47 +01:00
xchangcheng
d81c497372 Merge "Teach PermissionBackend to accept plugin defined project permission" 2019-03-13 12:30:43 +00:00
Alice Kober-Sotzek
1da1862f0d Fix casing of change states for /related endpoint
Our REST documentation mentions that the status contained in
RelatedChangeAndCommitInfo has one of the values NEW, MERGED,
and ABANDONED. It explicitly lists them in upper case. In addition,
our frontend depends on the exact casing of those values.

This regression was introduced as a side-effect of I9ed389b01. Add a
test to prevent future regressions.

Bug: Issue 10559
Change-Id: I7486b71899c57e185d90d7357873834539933637
2019-03-12 13:45:18 +01:00
Edwin Kempin
f3db4fee35 AccountsImpl: Fix exception message if account cannot be parsed
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Icc23e19e1e7237368b3238690827c4ec8e5f5bfd
(cherry picked from commit d5a590379cd15907c857d4b9afd293738beabb10)
2019-03-12 10:21:36 +00:00
Patrick Hiesel
bd8e1a22fc Merge "Use the same ListChangeOptions in test that PolyGerrit uses, fix action" 2019-03-12 10:06:01 +00:00
David Pursehouse
b750d007c5 Merge branch 'stable-2.16'
* stable-2.16:
  Fix account and group query with Elasticsearch 6
  Fix support for "SystemVerilog"
  Add "Show Relative Dates In Changes Table" to settings preference
  Update syntax highlighting class

Change-Id: I0189b0e27d923d638aee2bc5779dca7261084841
2019-03-12 10:37:18 +09:00
Jacek Centkowski
17329c7629 Fix account and group query with Elasticsearch 6
When querying against Elasticsearch 6, gerrit uses the following
URLs:

  http://elasticsearch:9200/gerrit_accounts_0010/accounts/_search
  http://elasticsearch:9200/gerrit_groups_0007/groups/_search

whereas it should use:

  http://elasticsearch:9200/gerrit_accounts_0010/_doc/_search
  http://elasticsearch:9200/gerrit_groups_0007/_doc/_search

The type is properly resolved through the index adapter, so use that
to build the ElasticQuerySource instead of using hard coded constants
for both accounts and groups indexes.

Bug: Issue 10591
Change-Id: I90cd74da9246f56bc9b2ef8464587ab04152876b
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
2019-03-12 09:54:52 +09:00
Edwin Kempin
d5a590379c AccountsImpl: Fix exception message if account cannot be parsed
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Icc23e19e1e7237368b3238690827c4ec8e5f5bfd
2019-03-11 10:27:21 +01:00
David Pursehouse
4b4712c046 Merge branch 'stable-2.16'
* stable-2.16:
  Strip trailing slash at the end when creating repos
  Add support for cherry-picking even with merge conflicts

Change-Id: I1656c751d3ac3ef6de27085b6d004249923e75d4
2019-03-09 17:13:56 +09:00
Paladox none
09e31071c7 Strip trailing slash at the end when creating repos
Bug: Issue 7192
Change-Id: I1106899b8afb52f1cf04e46b87b6658f4664af09
2019-03-09 15:24:06 +09:00
David Pursehouse
a22679d067 Merge "Merge branch 'stable-2.16'" 2019-03-09 02:05:45 +00:00
David Pursehouse
a6dab5228b Merge "Remove remnants of project-specific themes support" 2019-03-08 23:59:56 +00:00
Paladox
6967cbe107 Merge branch 'stable-2.16'
* stable-2.16:
  Fix mobile display on gr-create-change-dialog
  LogThreshold: Allow the annotation to be inherited
  Do not show "Patch file" if change does not have a parent
  Fix support to use "Default Base For Merges" preference
  Re use gr-diff-preferences inside gr-settings-view
  Fix avatars not showing correctly

Change-Id: I26b8326304343bbe665b3ddcac401dc7b355a2bc
2019-03-08 17:46:37 +00:00
Patrick Hiesel
05e7f30810 Start caching top-menus and version
We want to reduce QPS to Gerrit where easily possible. The framework for
this is already in place: On every Response, we can set caching.

We don't want caching to impact users by showing them stale data that is
in the critical path of their work. For admins, this is slightly more
acceptable.

To start with, we cache /server/version (30s) and /server/top-menus
(300s). These only change if Gerrit gets upgraded or plugins that
contribute top-menus reload.

Change-Id: I33ef5792bffba79bde5d7e7dda6b4291f2db9cc7
2019-03-08 13:09:22 +01:00
David Pursehouse
674db51505 LogThreshold: Allow the annotation to be inherited
With the current implementation the log threshold is only set when the
annotation is done on the exact class, which means that in cases where
an abstract test class is extended by several derived test classes, it
is necessary to add the annotation on each derived class individually.

Allow the annotation to be inherited, so that it is possible to only
annotate the base class, and it will also be effective for all derived
classes.

Change-Id: I0501b2a617161a391478313b6f9891108bdf9969
2019-03-08 09:50:10 +00:00
David Ostrovsky
6def400a30 Add new change permission: Toggle Work In Progress state
Allow to grant the ACL to arbitrary users using new permission to
control who is able to flip the Work In Progress bit in addition to
three different groups allowed to toggle Work In Progress state: change
owner, server administrators and project owners.

Feature: Issue 10385
Change-Id: I66f6078936c4fae20f3a12dbd3a5d9a244eb75cb
2019-03-08 05:17:31 +00:00
Changcheng Xiao
fd1f18eff9 Teach PermissionBackend to accept plugin defined project permission
This commit allows plugins to define project permissions
and updates the PermissionBackend interface to accept
plugin defined project permissions.

This commit doesn't implement the strategies for handling
plugin project permissions and leave it to follow-up
commits.

Change-Id: Ib9d8d80045e50d51237da6d420aa9bfe001ca207
2019-03-07 18:24:51 +01:00
Changcheng Xiao
abe1832128 Update some code to respect some java best practices
This commit updates some code introduced by I977a77286f
to improve its readability and also honor some java best
practices, e.g.:
* explicitly prohibit inheritance if a class isn't
intended for that (Effective Java Item 19's advice:
design and document for inheritance or else prohibit it).
* Write unit tests in three sections, aka "arrange",
"act", "assert".

Change-Id: I8939370f16c2465c7ba102afd3877a31babd0c89
2019-03-07 13:16:29 +01:00
xchangcheng
aca985512c Merge "Allow plugins to declare project permissions" 2019-03-07 07:49:29 +00:00
Han-Wen Nienhuys
f013518c72 AsyncReceiveCommits: fix latency metric for AUTOCLOSED changes
Change-Id: I0b0bd8c002c74ffe10f79b3b0ae9264ce7547097
2019-03-06 12:55:23 +01:00
Patrick Hiesel
41e6fc98d4 Use the same ListChangeOptions in test that PolyGerrit uses, fix action
ChangeIT#changeDetailsDoesNotRequireIndex should detect when we regress
in adding a dependency to the change index to rendering a single
change's details page.

This commit brings the options in line with PolyGerrit and is more
generous in swallowing an exception in a single UI action that made the
test - hence rendering the page when the index is unavailable - fail.

Change-Id: If3783fd258bcd5a133b01cf1ce41a3522fd9b535
2019-03-06 09:58:28 +01:00
Patrick Hiesel
6daaffbb2d Merge "Fix child collection bindings in RestApiServlet and add tests" 2019-03-06 07:52:26 +00:00
Edwin Kempin
645a0c0215 Merge "Forbid '\0' in commit messages edits" 2019-03-06 07:41:11 +00:00
Dave Borowitz
d9679cdb60 Add an index-safe predicate that matches all changes
Iad564dd47 was problematic in the error case because it returned
Predicate.not(Predicate.any()). The "any" predicate is not an index
predicate, which produces at least two problems:

* When used in a with another non-index predicate, it
  might throw "no ChangeDataSource" from AndSource/OrSource.
* More dangerously, when combined with an index predicate, it is used as
  a post-filtering predicate. A post-filtering predicate that matches no
  results means it gets applied to every change in the index before
  returning an empty set, which is bad.

Instead, reuse a handy existing index predicate that is designed to
return no results efficiently from the index:
ChangeStatusPredicate.NONE. Expose this from a more general location,
ChangeIndexPredicate#none().

Change-Id: Ic9a7e277070cff7768ec91c1972cf8e9f6deacb1
2019-03-06 00:31:58 +00:00
Patrick Hiesel
809e8e108b Fix child collection bindings in RestApiServlet and add tests
The Gerrit Plugin injector and the RestApiServlet currently have
different bugs. This commit papers over the most pressing ones and adds
tests so that plugins can bind child collections and offer modifications
directly on the collections (e.g. postOnCollection).

When binding rest views from plugins, the plugin name is incorrectly set
to "gerrit" which is what we use for core Gerrit views. This does not
apply to collections though. These are bound with the correct plugin
name "plugin-name".

In RestApiServlet, this leads to a situation where the collection thinks
it belongs to a different part of Gerrit. For operations that modify the
collection (post, delete) this means we have to use "gerrit" as the
component name when looking up child views. For root collections, we
already do this and this is why it works for existing plugin root
collections. For subcollections, however, we did not - which is what
this commit changes. Now the two usages in RestApiServlet are
consistent.

To be clear: They are now consistently wrong across the different parts
of Gerrit, but they are consistent which means they work.

As future work, we want to fix this long standing issue by binding the
correct plugin names from the beginning. This is non-trivial though
because the DynamicMapProvider has no context on the plugin that is
performing the binding.

This commit adds the same logic that we have for core-collection
delegation to plugin-collections in RestApiServlet.

Change-Id: I954105155c4a354b6c577d8cc246d00998e33f57
2019-03-05 17:45:20 +01:00
Changcheng Xiao
8673c3b667 Allow plugins to declare project permissions
This commit makes it possible for plugins to declare
project permissions like what they are doing for
capabilities.

In the access section of a "project.config" file,
a plugin delcared permission is stored in a format
like "plugin-{pluginName}-{permission}" so that we
can tell if a config name could possibly be a plugin
permission with some confidence. This is helpful
when we load/save "ProjectConfig" where listing
plugin defined permissions is not trivial, e.g.
DynamicMap doesn't present when a test site is
initialized.

Note plugin declared capabilities have to keep the
old format "{plugin-name}-capability" before a data
migration is done.

In the child commit, we are going to extend
the "PermissionBackend" to accept project permissions
declared by plugins.

Change-Id: I977a77286f56214f90a5ff6a5b482e2701cf9916
2019-03-05 17:34:00 +01:00
Changcheng Xiao
4fc7c5ceb8 ConflictsPredicate: don't split log statements
Change-Id: I66a7352ed8af48ea1e8a794e81e76ebe4eb82c8c
2019-03-05 06:59:21 -08:00
Dave Borowitz
d26237eaa8 Merge "ConflictsPredicate: Suppress all checked exceptions" 2019-03-04 18:47:12 +00:00
Edwin Kempin
c0efebb4fd Merge "SetPrivateOp: Include non-open change's status in exception message" 2019-03-04 12:39:34 +00:00
Han-Wen Nienhuys
58b87f6ce8 Forbid '\0' in commit messages edits
Change-Id: I150aaa32e40ca44f3b21727a3955774ff2abb77b
2019-03-04 12:00:40 +01:00
David Pursehouse
3fbdf98c9a Remove remnants of project-specific themes support
Project-specific themes were only implemented in the GWT UI, which has
been removed.

Remove the ThemeInfo entity, and no longer include the 'theme' field in
the ConfigInfo entity returned by the project config REST API endpoint.
This is a breaking change for any client that still uses that endpoint.

The custom site header HTML, footer HTML, and CSS files are still used
by login screens and the internally managed Gitweb server. Update the
theme documentation to mention this.

PolyGerrit has site-wide theme support, but it is not documented in the
existing config-themes.txt, and adding it is not within the scope of
this change.

Change-Id: Ibe824a9416fac65bd365407b8ce22e03515b5b52
2019-03-02 05:10:44 +00:00
David Pursehouse
cbb84d9aef Merge changes If23c598d,I5fd1a074
* changes:
  MergeUtil: Add debug logging to PluggableCommitMessageGenerator
  Expand acceptance tests for ChangeMessageModifiers
2019-03-01 22:15:34 +00:00
Dave Borowitz
8552187693 ConflictsPredicate: Suppress all checked exceptions
When the conflicts operator fails, the result is not actionable, and the
UX is bad in the PolyGerrit UI, producing a modal error dialog. The
conflicts operator is already known to be subject to false positives and
false negatives; this just replaces some errors with silent false
negatives.

This code is in a bit of an odd situation where the actual stack trace
is useful[1], but it's extremely long and noisy to log every time. Log a
single line most of the time, and a stack trace every once in a while.

[1] It's how I found https://git.eclipse.org/r/137886

Change-Id: Iad564dd4708080e8dabc88e9ad1ad7521ec6b603
2019-03-01 10:50:20 -08:00
Dave Borowitz
4dbcfd2a06 MergeUtil: Add debug logging to PluggableCommitMessageGenerator
Change-Id: If23c598d9bbaa16d3fa056d8d656b4ab87a34470
2019-03-01 07:54:47 -08:00
David Pursehouse
61b8feff59 SetPrivateOp: Include non-open change's status in exception message
Instead of saying "a non-open change", use the actual status of the
change, i.e.:

  cannot set abandoned change to private
  cannot set merged change to private

Adjust the setMergedChangePrivate test accordingly, and also add a
new test to cover the abandoned change use case.

Change-Id: I896f20b68e82edf1341c898ab2c0ba680cde1d69
2019-03-01 13:47:49 +09:00
David Pursehouse
8560a9cc3c Merge "Consistently use ChangeUtil#status" 2019-02-28 23:14:57 +00:00
David Pursehouse
aed5229dcf Merge "Use replace instead of replaceAll where regex is not needed" 2019-02-26 23:13:59 +00:00
David Pursehouse
1ad4cf8fe3 Merge "Implement RevisionNote#getOnlyEntity" 2019-02-26 14:25:03 +00:00
Saša Živkov
24e650d93a Use replace instead of replaceAll where regex is not needed
There seem to be an reoccurring mistake of using String.replaceAll
instead of the String.replace. The method names are misleading and one
may think that the replace method replaces only the first occurrence and
the replaceAll method replaces all occurrences.

Actually, both methods replace all occurrences. However, the replace
method interpretes the first parameter as the plain string while the
replaceAll method interpretes it as a regex. Using the replace method
when regex support is not needed improves both performance and
readability.

Change-Id: Iffed6aae4d7b541e4dc76e4b5bd20dcd8d5bad49
2019-02-26 14:32:55 +01:00
David Pursehouse
08672c368b Merge branch 'stable-2.16'
* stable-2.16:
  ChangeCleanupConfig: Remove unnecessary usage of regex in URL replacement
  AbandonIT: Add tests for changeCleanup.abandonMessage
  UrlFormatter#getChangeViewUrl: Remove @Nullable and simplify default implementation
  UrlFormatter#getSettingsUrl: Annotate section parameter as @Nullable
  MergeUtil: Include project name in "Reviewed-On" URL
  ChangeCleanupConfig: Inject UrlFormatter via DynamicItem
  Adjust more classes to inject UrlFormatter via DynamicItem
  Set version to 2.15.12-SNAPSHOT
  Set version to 2.15.11
  Allow LFS-over-SSH created auth pass through ContainerAuthFilter
  Upgrade elasticsearch-rest-client to 6.6.1
  ElasticContainer: Bump the test server version to 5.6.15

Change-Id: Ie90d450ddb16d165ed2d5ec91964d35b735214dd
2019-02-26 21:17:53 +09:00
Patrick Hiesel
903b23c118 Implement RevisionNote#getOnlyEntity
RevisionNote is currently only used with lists. For the checks plugin we
want to use it to represent a map. Therefore, offer a getOnlyEntity
method to make sure we always just deal with a single entity.

Change-Id: I15b93e2517ce2dd3d8a6c421d5d8e7ac04c28220
2019-02-26 10:00:03 +01:00
David Pursehouse
0f652022f0 ChangeCleanupConfig: Remove unnecessary usage of regex in URL replacement
Change-Id: If5f3a1ee2c28ee9f9b75b7a5b77018df3d2cdb74
Reported-by: Saša Živkov <zivkov@gmail.com>
2019-02-26 17:44:20 +09:00
David Pursehouse
76294ee83e UrlFormatter#getChangeViewUrl: Remove @Nullable and simplify default implementation
There are no longer any callers in core that pass null project to
this method. Remove the @Nullable annotation and simplify the default
implementation.

Change-Id: I4359527e0167712a9d68efe08eb86392daa38f13
2019-02-26 17:27:10 +09:00
David Pursehouse
56d17e9ead UrlFormatter#getSettingsUrl: Annotate section parameter as @Nullable
Change-Id: I7213240c7177cf217b590b866817c3fd3a7d3dab
2019-02-26 17:27:10 +09:00
David Pursehouse
5c25c04004 MergeUtil: Include project name in "Reviewed-On" URL
The method UrlFormatter#getChangeViewUrl has the @Nullable annotation
on the project argument, allowing the project name to be omitted from
the URL.

The URL used in the Reviewed-On footer, which is added to the detailed
commit message, is the only place that passes null for that parameter,
and as a result this is the only place in Gerrit where the change URL
does not include the project name.

Bug: Issue 10512
Change-Id: Ib6737af0a72adb7706caa20991780be71617dd24
2019-02-26 17:27:10 +09:00
David Pursehouse
0b3d333ca6 ChangeCleanupConfig: Inject UrlFormatter via DynamicItem
Since change I375245647 the UrlFormatter is bound as a DynamicItem,
so it should also be injected as such.

For this class we can't simply change the constructor parameter since
the UrlFormatter is not stored as a member but is used to initialise
the abandon message, which may have a $URL placeholder which is used
to replace with the actual URL provided by the UrlFormatter.

Change it so that the abandon message is initialized in the construcor
as before, but the replacement of the $URL placeholder is only done at
the time the message is needed.

Bug: Issue 10500
Change-Id: If4299276ec94402e8d2b806ad179e185e307d1ab
2019-02-26 17:27:10 +09:00
David Pursehouse
27daa2c652 Adjust more classes to inject UrlFormatter via DynamicItem
Since change I375245647 the UrlFormatter is bound as a DynamicItem,
so it should also be injected as such.

Adjust most remaining classes to do that. The only one remaining is
the ChangeCleanupConfig which requires slightly more invasive changes
and will be done in a separate commit.

Bug: Issue 10500
Change-Id: Ie9eeef11bd5ce63168bb339e22ee3062482ddd25
2019-02-26 17:27:10 +09:00