973 Commits

Author SHA1 Message Date
David Pursehouse
42ace3c4f4 Format java files with google-java-format
google-java-format was not run after squashing string concatenations
in change I7348413ae.

Change-Id: I30afb262cca64e7638657d59ebb81938c22f0242
2017-02-17 13:21:04 +09:00
David Pursehouse
1111684821 Squash redundant string concatenations introduced by google-java-format
Reformatting the code with google-java-format tool in change Id5f3c6de9
resulted in wrapped lines being unwrapped to the new 100 columns limit.

In cases where the wrapped line was wrapped on a string concatenation,
the resulting long line now includes redundant concatenations. See the
upstream issue [1] for an example of this.

Squash the redundant concatenations with:

  git ls-files | grep java$ | xargs sed -i '' 's/" + "//g'

(note: this also resulted in a couple of unwanted changes; those are
manually undone.)

[1] https://github.com/google/google-java-format/issues/122

Change-Id: I7348413ae460c8c7a0b0c72dab0a1ae7275a2ec3
2017-02-17 08:57:46 +09:00
ekempin
fe639c72e0 Merge "Use Gerrit person identity for commits created during init" 2017-02-16 06:50:26 +00:00
David Pursehouse
71f21fdb0b Init{Auth|Sshd}: Remove unused Libraries members
Change-Id: I93430d156546eaad84098bce78893af353c37099
2017-02-16 10:46:46 +09:00
Han-Wen Nienhuys
6471e8a94a Ship BouncyCastle in the .war files.
Per
https://www.bis.doc.gov/index.php/forms-documents/encryption/328-flowchart-2/file
open source crypto software can be self-classified as 5D002, and
requires only notification of the U.S. Bureau of Industry and
Security.

This registration has been performed by Google, as of Feb 15, 2017.

This gets rid of the special casing for BouncyCastle, simplifying our
build and deployment process.

Change-Id: I680b0a001e5e2e497ed6e62c90c8b8be30efff48
2017-02-15 13:48:57 +01:00
Edwin Kempin
f94768b73f Use Gerrit person identity for commits created during init
During init we can't get GerritPersonIdent injected which is why we
created an init person identity. Instead we can just create the real
Gerrit person identity via GerritPersonIdentProvider.

Change-Id: Ic23905657fbf9ced80d37d51726f8aa75e0a2259
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-02-15 13:02:45 +01:00
Dave Borowitz
bf4224bc2f Merge "Assign unused Future return value to a variable"
* submodules:
* Update plugins/reviewnotes from branch 'master'
  - Assign unused Future return value to a variable
    
    Error Prone plans to make this pattern into a compile error; this avoids
    future breakage.
    
    Change-Id: I6a023f22f472941854a6729f6450b9b70a020069
2017-02-08 13:58:39 +00:00
David Pursehouse
7dbec98c26 Merge branch 'stable-2.13'
* stable-2.13:
  ProjectQoSFilter: Remove unnecessarily nested else-block
  Revert "Resolve username lazily in git over http tasks"

Change-Id: Ie55393880b41e151847489bd1f4959702695b5fb
2017-02-08 16:36:09 +09:00
David Pursehouse
c8acb9ae0d ProjectQoSFilter: Remove unnecessarily nested else-block
Change-Id: Icabeaa9cedf50a84da62ab67d24355928fae8fbb
2017-02-08 16:31:09 +09:00
David Pursehouse
5b15aedeb2 Merge branch 'stable-2.12' into stable-2.13
* stable-2.12:
  Revert "Resolve username lazily in git over http tasks"

Change-Id: I574e70a57f4a53487a2bd83b38e321ba13deaa31
2017-02-08 16:11:02 +09:00
Hugo Arès
62e6711dcd Revert "Resolve username lazily in git over http tasks"
This reverts commit 3fd92a4ac50e5ef49043858ab2576050634a3c2e.

The change was supposed to print the username in the queue for git over
http operations but the username printed is the one of the person doing
show-queue, not the one doing the git operation.

Change-Id: I2f45d526b684af9f3aa336879b310a165048382e
2017-02-07 18:22:28 +00:00
Dave Borowitz
9189e67c3d Assign unused Future return value to a variable
Error Prone plans to make this pattern into a compile error; this avoids
future breakage.

In some of these cases, it's not obvious that ignoring the return value
is the correct thing to do; the hope is that the construct is ugly
enough to make the author think twice. In many cases though, it's clear
that a locally-created Runnable or Callable already does its own error
handling, so we can leave a comment alongside the ignored return value.

Eventually many of these should be audited again, and we can replace
some of the @SuppressWarnings with Error Prone's @CanIgnoreReturnValue.
That much is left for future cleanup.

Change-Id: Ia989214d85e0d6c387e388a77178e0b5c4bf2498
2017-02-07 10:43:12 -05: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
Saša Živkov
4115c449a3 ProxyUtil: make use of String.isNullOrEmpty
Change-Id: Iec4b57e2ebe39b3ff69af427343851d88de80cef
2017-02-06 08:33:30 +01:00
David Pursehouse
7d62e54a07 Merge branch 'stable-2.13'
* stable-2.13:
  MetaDataUpdate: Do not close repository that was passed in
  BaseInit: Bind DisabledMetricMaker
  Update git submodules

Change-Id: Ibd32b0e2b5493d16e4404bf9207cb0c59a829c1d
2017-02-03 20:26:57 +09:00
David Pursehouse
48d05ea980 BaseInit: Bind DisabledMetricMaker
In some cases a plugin may have an InitStep that refers to other
classes in its implementation, that in turn get a MetricMaker
injected.

Since the MetricMaker, among other things, is not available to
the InitStep, this results in a guice injection error during the
plugins init step of site initialization.

Bind the DisabledMetricMaker to avoid the injection error. This
has the result that the InitStep works, but no metrics can be
recorded. Update the metrics documentation to explicitly mention
that metrics are not available during plugin init steps.

Bug: Issue 5438
Change-Id: Iac9f462eb93a2ae668d5c934e61eda9f23bd3c4d
2017-02-03 19:37:02 +09:00
Edwin Kempin
79e63a39e4 Revert external ID cache
It make more sense to include the commit SHA-1 of the notes branch from
which the external IDs have been read into the cache key. This makes it
easier to implement this cache within a multimaster setup.
However, obviously, we can include the commit SHA-1 of the notes branch
into the cache key only after the external IDs have been migrated to
NoteDb (because before this the notes branch does not exist yet).
Revert the cache for now and re-add an improved version of the cache
later with the change that implements the migration of the external IDs
to NoteDb.

This reverts the following commits:
- 2869caaf70569fcf777676d605f9d7e70c4ac36d:
  Add cache for external ids
- 48d5c9b9aa8aba3de52374328e2a1cc30be64a10:
  Make ExternalIdCacheImpl.AllKey public
- 20e5507d46c2a266e73974878685c74adfd6ff6b:
  ExternalIdCache: Add method to get external IDs by account ID + scheme

Change-Id: I589242aad32a9c70718542ba950c0a351c594e54
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-02-02 17:27:43 +01:00
Edwin Kempin
97f74f081d Add support for performing checks on Gerrit start up
This allows to do checks on Gerrit startup and abort the Gerrit startup
if issues are found. E.g. this allows us to do validation on the Gerrit
config, which is needed by a follow-up change.

The startup checks are done after all lifecycle listeners have been
invoked so that logging is already available and the reason for a
failing startup can be written to the error log.

All implementations of StartupCheck should be bound in
StartupChecks.Module.

Change-Id: I941dad2c926130a1f9c5a1a363f7e1eff0dab304
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-31 16:47:14 +01:00
Edwin Kempin
791d2d9f05 Use write indexes to index groups/accounts during init
Change-Id: I426456086f2a7935dd79c831005dbb8013b758a6
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-27 16:14:48 +01:00
Paladox none
5ec42df72b Fix SHA1 for mysql-connector-java
Follows up Ica634e04b43a64ac5fc449d76aef81a88806b876

https://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.40/mysql-connector-java-5.1.40.jar.sha1

Change-Id: I560a5484708948c8b8b0251473523103d6a05ecf
2017-01-25 22:04:43 +00:00
Paladox
f2805cd30e Update mysql-connector-java to 5.1.40
See release notes at
http://dev.mysql.com/doc/relnotes/connector-j/5.1/en/news-5-1.html

We should upgrade to 6.x after this as that release supports java 8.

Change-Id: Ica634e04b43a64ac5fc449d76aef81a88806b876
2017-01-25 01:43:05 +00:00
David Ostrovsky
fdbfcad77d Remove Buck based build
Bug: Issue 5302
Change-Id: I6e860446ef30ff0ad1c7c49fc0e39d39d921820b
2017-01-23 12:44:58 +00:00
David Pursehouse
eaee6f44bb Merge branch 'stable-2.13'
* stable-2.13:
  Fix gitweb review link
  Install "git-lfs-authenticate" SSH command when lfs.plugin is configured
  Introduce "git-lfs-authenticate" SSH Command for LFS plugins

Change-Id: I368009619cb8550e059a60e9de9e7ac83e173090
2017-01-20 10:46:43 +09:00
Dave Borowitz
0ecf8cf401 Avoid Multimap implementation create methods
Guava team recommends MultimapBuilder over specific Multimap
implementations, so callers don't have to know the specific key/value
behaviors of the individual implementations. The static factory
methods in the implementations will be removed in a later version.

LinkedListMultimap and LinkedHashMultimap are not affected, since
MultimapBuilder lacks support for specifying linked entries, and thus
the factory methods are not in immediate danger of deletion.

Change-Id: I7744db687da84a7beae31d1cb8953e782ed23c1d
2017-01-18 10:37:06 +09: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
Jacek Centkowski
31235233d0 Install "git-lfs-authenticate" SSH command when lfs.plugin is configured
SSH command registration was extended so that command gets registered
only in case when plugin is configured in gerrit.config.

Change-Id: Iffaf00775bdf1242e1fbe1dea15e5ce0bf912079
Signed-off-by: Jacek Centkowski <geminica.programs@gmail.com>
2017-01-16 14:11:53 +00:00
David Pursehouse
265172aca9 Merge "Index admin user account that is created during init" 2017-01-12 23:16:43 +00:00
David Pursehouse
4f686700ff Merge "Merge branch 'stable-2.13'" 2017-01-12 06:54:20 +00:00
David Pursehouse
6c5fa05cdd Merge "Add cache for external ids" 2017-01-12 05:38:56 +00:00
David Pursehouse
546532c4ad Merge "Update bouncy castle to 1.56" 2017-01-12 05:38:08 +00: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
David Pursehouse
3e9fb7fe82 Merge branch 'stable-2.13'
* stable-2.13:
  Gerrit command line utility to set/update secure.config
  Fix naming and message prompt for entering passwords
  Don't truncate long lines in diff screens

Change-Id: I2210d94e0bc7374eff26614145e3a76b526177f5
2017-01-12 11:00:18 +09:00
Luca Milanesio
b10848ee83 Gerrit command line utility to set/update secure.config
When using a secure store for encrypting the secure.config
values, an utility or tool is needed to edit the values
using the same encryption key used by Gerrit at runtime.

Change-Id: Iacb017b010f7efd8217255796e571c5291499c0e
2017-01-12 00:25:25 +00:00
Paladox
10649e4550 Update bouncy castle to 1.56
See release notes at https://www.bouncycastle.org/releasenotes.html

Change-Id: Id0c5b1e929118469b4a80252e44a201b7b8f62f5
2017-01-11 23:05:10 +00:00
Luca Milanesio
f6dd9ebe96 Fix naming and message prompt for entering passwords
Change-Id: Ia3a15e9070ce3b284c84f2ac02a82e3c277dd5c3
2017-01-11 14:59:02 +00:00
Edwin Kempin
2869caaf70 Add cache for external ids
Introducing a cache for external ids is a preparation step for moving
the external ids from ReviewDb into NoteDb. For NoteDb it is planned
to store the external ids in a git note branch, where the note keys
are the sha1's of the external ids and the note values contain the
external id, the account id and optionally email and password. With
this format we can easily lookup external ids by the external id, but
listing all external ids of an account requires parsing all external
ids. Looking up the external ids of an account is possible from the
account index, however for reindexing an account we would still need
to lookup all external ids of the account from git. Having a cache for
the external ids ensures that the external ids are only loaded once
from git. If there is any update to external ids, we take care to
update the cache as well. For this change it means that all code that
modifies external ids must do an extra call to update the external id
cache. This is not optimal since updating the cache can be easily
forgotten. This is why the follow-up change cleans this up by
introducing a dedicated class that handles all external id updates and
then this is the only class that must take care to update the external
id cache.

Change-Id: I9ea979c646cddb9b39e723de5c061a70a2ce6fd6
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 14:32:21 +01:00
David Pursehouse
74992d3822 Merge branch 'stable-2.13'
* stable-2.13:
  Resolve username lazily in git over http tasks

Change-Id: Ib247a320d684da5d1e3d011663bbd9ca7d9c347a
2017-01-11 20:12:27 +09:00
Edwin Kempin
1412ccfadf Index admin user account that is created during init
During the initialization of a new site the InitAdminUser init step
may create an account for the initial admin user. This new account
must be added to the index so that it becomes queryable. For this init
must have the account index available so that it can write the new
account to it. Reading from the index during init is not needed and
not supported.

Alternatively we could require users to run the Reindex program after
the initial site initialization, but likely many people would forget
about it and then wonder why the initial admin user is not working.

Change-Id: Iebee152fa0b28df3fe59da74ad688c4373488c53
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 11:59:27 +01:00
Edwin Kempin
a4c095f171 Index groups that are created during init
During the initialization of a new site some default groups are
automatically created ('Administrators' and 'Non-Interactive Users').
These new groups must be added to the index so that they become
queryable. For this init must have the group index available so that
it can write the new groups to it. Reading from the index during init
is not needed and not supported.

Alternatively we could require users to run the Reindex program after
the initial site initialization, but likely many people would forget
about it and then wonder why the default groups are not available from
the group index.

Change-Id: I274b142a6efde224bba68f8b5c459736d7a1f985
Signed-off-by: Edwin Kempin <ekempin@google.com>
2017-01-11 11:59:27 +01:00
David Pursehouse
c7fd1c00d3 Merge branch 'stable-2.12' into stable-2.13
* stable-2.12:
  Resolve username lazily in git over http tasks

Change-Id: Ie55ab6a57613e4eed04835718437cc0fbf9c3592
2017-01-11 13:40:42 +09:00
Hongkai Liu
3fd92a4ac5 Resolve username lazily in git over http tasks
ProjectQoSFilter uses username as a part of task info. However,
AuthFilter which comes later than ProjectQoSFilter renders the
value of username. As a result, username never gets resolved when
using git with http.

The current patch set resolves the username only when it is used,
i.e., in the toString method, and saves the value for reusage.

Bug: Issue 5206
Change-Id: I280c95b242d599919eee3c7007c60a0047170166
2017-01-04 16:39:49 -05:00
David Ostrovsky
944b51634a JarScanner: Fix resource leak flagged by infer
This fixes resource leak with JarFile instance acquired by call to
ctor of JarScanner.

Bug: Issue 5198
Change-Id: I80feabcf9e0bfd683d1d8c47f3fd6c9be3ff65a6
2016-12-27 17:30:41 +00:00
Patrick Hiesel
a4c2df2ea0 Enable Sshd only if we run ssh tests
Change-Id: I40e37d166540e6480a48de2b093c69a49d15c18a
2016-12-23 08:30:31 +01:00
David Pursehouse
c1453ad3ab Merge branch 'stable-2.13'
* stable-2.13:
  Change kind cache: Don't fail if prior ps has no parent, but next ps has 1 parent
  Make Gerrit startup timeout configurable

Change-Id: I2e6a53eb33cbe2e3059e65bd72bf80ff65fc2f3b
2016-12-22 07:13:37 +00:00
Khai Do
6168beb499 Make Gerrit startup timeout configurable
Allow users to configure the maximum time to wait for the gerrit.sh
start command to run Gerrit.

Bug: Issue 5179
Change-Id: If6ad15b51081c26ff02ecb7ad513551733ce1f79
2016-12-20 08:24:08 -08:00
David Pursehouse
2768119c2f Merge "Send email notification to user that is assigned to a change" 2016-12-07 12:52:36 +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
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
Edwin Kempin
49ab6f597e Send email notification to user that is assigned to a change
Users want to get informed when they are assigned to a change. So far
there was no email notification on assigning a change to a user.

Change-Id: I7953b552f9814c283392b02520f5129e97cff9ff
Signed-off-by: Edwin Kempin <ekempin@google.com>
2016-12-07 12:02:18 +01: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