334 Commits

Author SHA1 Message Date
Dave Borowitz
798b883b40 Move ReceiveCommits and related classes to their own package
After naively moving the classes, there were almost no incoming
references from the rest of the server packages into the new
server.receive package. This means with only a little more work, it was
possible to create a new java_library target containing just the srcs
in this new package. This is a modest step in the direction of breaking
up the giant //gerrit-server:server package, which will improve compile
times when making modifications that don't change the interface.

Change-Id: I449018a4933a999c688611142dc7ed9c18b4c828
2017-08-08 10:50:06 -04:00
Dave Borowitz
dece981249 Rework NotesMigration hierarchy and get rid of test impl
It used to be that ConfigNotesMigration was the only kind of
NotesMigration in a real server, but it was always immutable, while
TestNotesMigration was the main kind of migration in acceptance tests,
which was mutable. However, now that we support modifying
ConfigNotesMigration at runtime as part of the online NoteDb migration
process, TestNotesMigration is no longer strictly necessary, and
continuing to support it is becoming more trouble than it's worth.

One major problem was that only TestNotesMigration was being populated
via NoteDbMode, and the NoteDbMode was not reflected in the
ConfigNotesMigration at all, so callers that were depending on
ConfigNotesMigration directly would not know about the NoteDb migration
state from the GERRIT_NOTEDB env var in tests.

We could have fixed this (and other) problems directly, but there is a
better solution: get rid of the test implementation entirely, and use
the same implementation of NotesMigration in tests as in a running
server.

The class hierarchy now contains only two classes: NotesMigration and
MutableNotesMigration. Most callers just care about inspecting the
state, so they can inject a NotesMigration. The few callers (migration,
tests) that care about mutating the state at runtime can inject/create
MutableNotesMigrations instead. As an implementation detail, the actual
NotesMigration instance continues to be mutable, containing a reference
to the Snapshot, but the base class does not contain any public methods
to mutate the state. We then ensure with Guice that there is only one
actual NotesMigration instance (the MutableNotesMigration), and callers
just may or may not have access to the mutation methods depending on
what they chose to inject.

Ensuring this gets set up correctly in tests requires a bit of tweaking.
  * Since the NotesMigration is populated in the @UseLocalDisk case from
    reading gerrit.config on disk, we need to prepopulate gerrit.config
    with the right config values at startup time.
  * Since MutableNotesMigration is not in the testutil package, it can't
    have its own setFromEnv() method that depends on NoteDbMode.
    Instead, construct MutableNotesMigrations from the test env by using
    a static factory method in NoteDbMode.

Change-Id: If06db3d025cf3e3c9fe464989d5f38a22ce70b56
2017-07-13 10:03:17 -04:00
David Pursehouse
64df83ae7d Use "gerrit" as the Gerrit user instead of "gerrit2"
We're still on Gerrit version 2.x but when we move to 3.0 it
will not make sense to have the user named "gerrit2".

Update all the documentation to refer to "gerrit" instead.

Also change the Jetty configuration to use "gerrit" instead.

Change-Id: I43a343669ac936b0585ee15e07d15643f9c3d6eb
2017-07-04 21:20:47 +09:00
Paladox
c7746ffec7 Merge branch 'stable-2.14'
* stable-2.14:
  Fix java.lang.ArrayIndexOutOfBoundsException when checking for parent
  ProjectTagsScreen: Fix title of revision field for new tag
  Fix cyclic dependency when using site_path from system_config table

Change-Id: I1f4ed09818885284b9686d38705a20cf21cfce23
2017-06-14 14:56:09 +01:00
David Pursehouse
b65c0af5ed Merge branch 'stable-2.13' into stable-2.14
* stable-2.13:
  Fix cyclic dependency when using site_path from system_config table

Change-Id: I519ee80c35190e1fe08d88522cbe64e464a44513
2017-06-14 20:58:12 +09:00
Han-Wen Nienhuys
b0fb0a7a96 Remove 'final' from method signatures across gerrit.
Change-Id: I986a5507aa26ceb28305a7b08991e85238bde0e3
2017-06-14 09:18:42 +02:00
Saša Živkov
d0b688d3ad Fix cyclic dependency when using site_path from system_config table
The starting mode where site_path is not specified (as a system property)
and Gerrit first connects to the database using the ReviewDb JNDI
property from the servlet container was broken since I60f585f5ef due to
a cyclic dependency in Guice bindings.

Make sure to inject the non-wrapped SchemaFactory<ReviewDb> in the
SitePathFromSystemConfigProvider.

Change-Id: Ie283a5498e981642a82aac1fcb8b33b0c881fc84
2017-06-13 12:57:12 +02:00
David Pursehouse
f05ee3fc73 Merge branch 'stable-2.14'
* stable-2.14:
  Fix documentation of the review command
  Fix online reindexing for plugins-dependent rules
  De-couple PluginModule and PluginRestApiModule registration

Change-Id: Ic6dd1c019e7a451f325d378b071f2347f82c2e44
2017-06-12 20:03:04 +09:00
Luca Milanesio
86a1dd735c Fix online reindexing for plugins-dependent rules
Online reindex recalculates the status of all the changes
by invoking the Prolog rules associated.
That is good in general but breaks systematically when the
rules depend on plugins for their accurate evaluation.

Noteworthy example is the use of singleusergroup plugin in
conjunction with user-specific ACLs for labels.
Another even more severe example is the use of custom
Prolog predicates in rules.pl provided by the owners' plugin.

By swapping the order of registration of the Plugins module
and the Lucene Index module, the lifecycle listener will then
load first the plugins and only afterward activate the online
reindexer.

Bug: Issue 6472
Change-Id: I87da6ac632d08aa915a57a01435cfa415b7de2f9
2017-06-12 11:46:20 +01:00
Luca Milanesio
c0ac1ba9c7 De-couple PluginModule and PluginRestApiModule registration
The registration of PluginModule and PluginRestApiModule needs to be
decoupled because they are conceptually separate, even if one (PluginModule)
needs to happen before the other (PluginRestApiModule).

This is a pre-requisite for the next change I87da6ac6 where the PluginModule
registration needs to be moved around without necessarily having an impact
on the PluginRestApiModule.

Change-Id: I80fee34e5bda5afb480c8d103e6e83b8ae11c8eb
2017-06-12 10:25:03 +01:00
David Pursehouse
873ffc483a Set version to 2.14.1
Change-Id: Ib0e026d1f0cfec80a902e1d1753fda5aafb57f63
2017-06-08 12:19:03 +00:00
David Pursehouse
1fec9396b3 Set version to 2.14.1-SNAPSHOT
The API includes some new classes since 2.14 and we need to be able
to build snapshot artifacts to test plugins that use the new classes.

Change-Id: Ifad31b93e5b5068c0d6952582f6882edc252e227
2017-05-26 11:20:43 +09:00
David Ostrovsky
946d6c3b14 Move prolog:common rule to gerrit-server root build file
Change-Id: Iacbff16b71d8464ccea6d2b631868e24a0605ec4
2017-05-18 06:17:11 +02:00
David Pursehouse
2ae3b327d6 Merge branch 'stable-2.14'
* stable-2.14:
  Update list of maintainers in pom.xml files

Change-Id: I59270a205415a040312e36f89a66c665953d5908
2017-05-15 16:42:35 +09:00
David Pursehouse
3c0899307e Update list of maintainers in pom.xml files
Change-Id: I9bc103431c674b892d696490e7638a2a2f4ac408
2017-05-15 16:27:18 +09:00
David Pursehouse
9cbfae0ada Merge branch 'stable-2.14'
* stable-2.14:
  ReviewersUtil: Fix candidate list multiplier comment
  Replace FileInputStream and FileOutputStream with static Files methods

Change-Id: I5c4e04457b680db7709c522f17cfef1bef91a60f
2017-05-10 15:47:26 +09:00
Hector Oswaldo Caballero
db21e3add0 Replace FileInputStream and FileOutputStream with static Files methods
FileInputStream and FileOutputStream rely on finalize() method to ensure
resources are closed. This implies they are added to the finalizer queue
which causes additional work for the JVM GC process.

This is an open bug on the OpenJDK [1] and the recommended workaround is
to use the Files.newInputStream and Files.newOutputStream static methods
instead.

[1] https://bugs.openjdk.java.net/browse/JDK-8080225

Change-Id: I3cef6fcf198dde2be7cd15bded8d2fa247177654
2017-05-10 00:10:52 +00:00
Shawn Pearce
0c80f2a6c3 Install DefaultPermissionBackendModule at daemon level
Move the binding out of GerritGlobalModule so it's part of the daemons,
making it easier to swap to a different PermissionBackend.

Expose DefaultPermissionBackend class as public so another backend
could wrap and delegate to DefaultPermissionBackend by accepting it
as an argument to its constructor.

Change-Id: I01f10d8a65d8942e73354bcf055c26b17d2606f9
2017-04-28 09:41:01 +00:00
David Pursehouse
03453bef90 Set version to 2.14
Change-Id: I5694579a543454322717a1d129e34d4140100479
2017-04-26 15:55:55 +02:00
David Pursehouse
74e4876d88 Merge branch 'stable-2.14'
* stable-2.14:
  Move systemctl files to /init/ rather than /systemd/
  SitePathInitializer: Fix destination file name for gerrit.socket
  Clarify documentation for accountPatchReviewDb.url
  Add the new gerrit systemctl file to init
  Remove unneeded output in MigrateAccountPatchReviewDb
  ES: Implement online reindex for ElasticSearch
  JdbcAccountPatchReviewStore: Fix copyright year
  Fix documentation nits in pgm-MigrateAccountPatchReviewDb.txt
  Support Jdbc implementation of AccountPatchReviewStore
  ES: Temporarily disable server discovery

Change-Id: I1034869bc6146db929f6242610c9eb13a7b092f7
2017-04-26 14:05:54 +02:00
David Pursehouse
a946880f07 Merge branch 'stable-2.13' into stable-2.14
* stable-2.13:
  Support Jdbc implementation of AccountPatchReviewStore

Change-Id: I27577b1df515d994d0f28a36d33b75110916d945
2017-04-26 10:21:46 +02:00
Hongkai Liu
49799b22fa Support Jdbc implementation of AccountPatchReviewStore
Provide in gerrit core support for alternative database backends
for AccountPatchReview store.

H2 was used for storing AccountPatchReview. This can become
problematic in large installation since embedded H2 cannot execute
concurrent requests even to the same database. The options related to
multi-thread in H2 are:
- MULTI_THREADED: a long running query blocks the ones in other
threads [1].
- MVCC: This is not production-ready yet, since it is not fully
tested [2].

AccountPatchReviewStore is an extension and a plugin could
implement a jdbc store but this would result in duplicated code
with core H2 implementation. Since core H2 implementation was
almost already compliant to jdbc standard, it's easy to make
jdbc url configurable in gerrit config and make the core support
other database than H2.

One could extend the H2 implementation in plugin, however the
changes on the supper class could lead to breaking plugin
implementation.

[1] http://www.h2database.com/html/features.html#multiple_connections
[2] http://www.h2database.com/html/advanced.html#mvcc

Change-Id: Ie61ac63a72cab71bd907886a794541cb3dea291e
2017-04-26 09:28:57 +02:00
Patrick Hiesel
e8bf91efaf Release 2.14-rc1
Change-Id: I85790145f2114b4ab9801a78fddc201e59766a8e
2017-04-24 16:03:54 +02:00
David Pursehouse
0450fde6ac Merge branch 'stable-2.14'
* stable-2.14:
  Add new Polygerrit maintainers to developers list in pom.xml files

Change-Id: I7f3e251081493b87e31075b1a1fa4779f8de1c4b
2017-04-22 06:33:24 +02:00
David Pursehouse
c211c0f9fa Add new Polygerrit maintainers to developers list in pom.xml files
Change-Id: I67bce6cb15e416f213633519bc1274a0aefddf35
2017-04-21 22:22:44 +02:00
David Pursehouse
05e558972c Merge branch 'stable-2.14'
* stable-2.14:
  Add new maintainers to developers section in pom.xml files
  Update Version to 2.14-rc0

Change-Id: Ib620c5f49ec5dee1a838c082f74b785689edba71
2017-04-12 09:44:54 +09:00
David Ostrovsky
6100054dbd Add new maintainers to developers section in pom.xml files
Change-Id: I2f6133a27e6f3a036f82442d5fcdc5a1b6c35f9a
2017-04-11 21:13:05 +02:00
Patrick Hiesel
ee94d108fe Update Version to 2.14-rc0
Change-Id: Ibafb67dcf186a6ec68f39009074cc210877979e5
2017-04-11 15:12:36 +02:00
David Pursehouse
fe862e319f Set version to 2.13.8
Change-Id: If81014e469b41d7ad093c5c56645f5b08eed2d87
2017-04-09 07:11:31 +00:00
Lucas Garron
b6a248327c Add a Retina (2x) resolution version to the default gerrit favicon.
Bug: Issue 5920
Change-Id: I93ac36c87b43edb4dd67c13089c7c9a08a3679bb
(cherry picked from commit baf902fae01677dc3042c8f60ba08be79af6c77c)
2017-04-01 11:51:30 +00:00
Lucas Garron
baf902fae0 Add a Retina (2x) resolution version to the default gerrit favicon.
Bug: Issue 5920
Change-Id: I93ac36c87b43edb4dd67c13089c7c9a08a3679bb
2017-04-01 00:50:28 +00:00
David Pursehouse
308f9cf920 Merge branch 'stable-2.14'
* stable-2.14:
  PolyGerrit: Bug fix for iOS 10.3 and mac 10.12.4
  Replace AbstractFileKeyPairProvider with FileKeyPairProvider in log4j config

Change-Id: Ic3c681c37ee5521e43008314324da4d6259b8d90
2017-03-30 09:20:53 +09:00
Paladox none
5db0e6f26c Replace AbstractFileKeyPairProvider with FileKeyPairProvider in log4j config
The AbstractFileKeyPairProvider class was replaced with FileKeyPairProvider
in the upgrade from sshd 1.2 to 1.4.

Change-Id: I711582ea01235849f40991fa7aefd13673aa2277
2017-03-30 09:17:36 +09:00
David Pursehouse
23fa65a65b Set version to 2.15-SNAPSHOT
Change-Id: I560b77a951558cc25a0fddd436540e9fed87975e
2017-03-23 21:11:23 +09:00
David Pursehouse
1b435832b2 Set version to 2.13.7
Change-Id: Ifefe36b432a69d0f0eeb183735cb21f9679a36b2
2017-03-22 10:09:31 +09:00
Paladox none
fd9f2e1109 Add support for MariaDB
Add support for MariaDB using MariaDB connector [1].

[1] https://github.com/MariaDB/mariadb-connector-j

Change-Id: I72496f93eb15e24093c8b9d9cda0b225342faa13
2017-03-18 08:02:48 +01:00
David Pursehouse
7e5e551c8c Merge branch 'stable-2.13'
* stable-2.13:
  Prevent circular module dependency when running in external container
  Update Documentation of Auto Site Initialization

Change-Id: Ibcbaf7e7b5af58dca5c9b32d068acb81d1fd9781
2017-03-01 11:16:51 +09:00
Thomas Meyer
d66f37c5ab Prevent circular module dependency when running in external container
Commit 220a3f5 introduced circular dependency between the database
module and NotesMigration (impl. class ConfigNotesMigration).

Having the site path being stored in the database was broken by above
change. The class Daemon solves this by explicitly setting the site
path and adds a SitePath module before starting everything.

This patch makes it possible again to run the gerrit war in an external
Servlet container, but you need to set the System property
"-Dgerrit.site_path=/path/to/gerrit" to make it work.

The site path stored in the database became practically obsolete with the
NotesMigration change mentioned above.

Change-Id: Id735fbf928dda186e659792c84d4e675c893a29a
2017-02-28 23:21:04 +00:00
David Pursehouse
a09e97bfba Set version to 2.13.6
Change-Id: Iff4e3dd171dbeca604d2eeb854ef162688ae84e4
2017-02-21 13:11:45 +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
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
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
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
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
481ba357bd Set version to 2.13.5
Change-Id: I120f598962d507db0a15121cad262f27475a71d9
2017-01-06 09:47:10 +09:00
David Pursehouse
af1d5a530d Set version to 2.13.4
Change-Id: Id5f193630beba6f77a51945e93e9ccc6cac7312c
2016-12-12 13:46:41 +09: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
Luca Milanesio
62cc3503b9 Support for loading Guice modules from /lib
Gerrit already has "pluggable" features that need to be installed
at the early stages of the bootstrap phase and cannot be "unplugged"
as plugins do.

Attendees at the recent hackathon in Mountain View decided to
call this new entities "LibModules", and configure them in the
gerrit.config as follows:

  [gerrit]
    installModule = com.googlesource.gerrit.libmodule.MyModule
    installModule = com.example.abc.OurSpecialSauceModule

Change-Id: Id8bf1a2e88b14c8e9125f20cb10a041d47799100
2016-11-18 14:26:47 -08:00
David Pursehouse
1dc6bfd3b9 Set version to 2.13.3
Change-Id: Ief9003913f7af82a849dab81fdd0b19c7b13c0e7
2016-11-15 18:34:46 -08:00