To run the tests:
bazel test //...
To build the Gerrit plugin API, run:
bazel build gerrit-plugin-api:plugin-api_deploy.jar
To build the Gerrit extension API, run:
bazel build gerrit-extension-api:extension-api_deploy.jar
TODOs:
Licenses
Reduce visibility (all public for now)
Generate HTML Documentation
Core plugins
gerrit_plugin() rule to build plugins in tree and standalone modes
GWT UI (only gwt_module() skylark rule is provided, no gwt_binary())
PolyGerrit UI
WAR
Publish artifacts to Maven Central
Ask Bazel team to add Gerrit to their CI on ci.bazel.io
Contributed-By: Han-Wen Nienhuys <hanwen@google.com>
Change-Id: I9a86e670882a44a5c966579cdeb8ed79b1590de3
The changeCache is null when in the context of BatchProgramModule.
The only consumer of changeCache, VisibleRefFilter, is prepared to
handle a null value, so in all code paths it is okay for it to be
null.
This makes reindex work again. Regression introduced in
a758640bc33c20cead19b86a32db075c776c4140 (VisibleRefFilter: Avoid
touching the database for drafts, 2016-06-03):
$ java -jar buck-out/gen/gerrit/gerrit.war reindex -d ../gerrit-testsite
[...]
Reindexing changes: projects: 66% (2/3)[2016-06-06 16:18:36,781] [Index-Batch-3] WARN com.google.gerrit.server.index.change.AllChangesIndexer : Failed to index change 18
com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) null returned by binding at com.google.gerrit.pgm.util.BatchProgramModule.configure(BatchProgramModule.java:126)
but parameter 8 of com.google.gerrit.server.project.ProjectControl.<init>() is not @Nullable
while locating com.google.gerrit.server.git.SearchingChangeCacheImpl
for parameter 8 at com.google.gerrit.server.project.ProjectControl.<init>(ProjectControl.java:177)
while locating com.google.gerrit.server.project.ProjectControl annotated with @com.google.inject.internal.UniqueAnnotations$Internal(value=4)
Reported-by: Viktar Donich <viktard@google.com>
Change-Id: Ia0ca0e0e153c9f357e5ebc6edf4b1962a2490f2d
This is an analogous problem to the one with search results fixed in
Ie54b9e2d. VisibleRefFilter is a little trickier because it was using
ChangeCache, which only returned Changes, not the reviewer set. Change
SearchingChangeCacheImpl to cache a different value type and return
ChangeDatas from its search method so we can use the cached
ReviewerSet where appropriate.
Unfortunately for the Reindex program we still need to support not
having a SearchingChangeCacheImpl, which means we have a completely
separate codepath for reading changes from the database.
Change-Id: Ic432a8e48a2bafc8d142b84b25101d95ffb674b7
When a DFS ref update of a NoteDb meta ref fails due to a transient
error in the storage backend, we don't want to incur an additional
write to the ref during reindexing, as it may just fail again. Worse,
while BatchUpdate knows to ignore NoteDb write updates when executing
its NoteDbUpdateManager, it can't as easily ignore them while getting
its index futures. Thus an error that was successfully ignored is
likely to be followed by one that can't be.
Work around this for the case of NoteDb writes enabled but reads
disabled, by explicitly turning off auto-rebuilding from
ChangeIndexer. This doesn't help us in the case of NoteDb reads being
enabled, where we have to be able to read the latest NoteDb data from
the ref in order to reindex.
Change-Id: I64000a57ffcf73a9cbef42a6130e1fb4bc8e98f0
The initial implementation allows to index specified changes. In future
this could be extended to allow indexing of changes by project/branch.
Change-Id: Ia66b086b8bd8d49fe536332d96e3292087fefa01
Move writeError from SetReviewersCommand to BaseCommand. Remove the
similar method from ReviewCommand and adapt the code to the slightly
different signature.
Change-Id: Ie6f326198ff87892f2f7dd6b1ec309d24cb35549
The taskNameWidth was actually used to limit the width of the command column
value(s). Therefore, rename it to maxCommandWidth.
Change-Id: I473aa0f2efe5c486b7d079581f68528cf38a3df1
It's not necessary to use Guava's helper methods when instantiating
empty collections. Just use the native constructors.
Change-Id: I7f454909b15924ee49e149edf9f053da9f718502
The public SSH keys of a user are now stored in an authorized_keys
file in the All-Users repository in the refs/users/CD/ABCD branch of
the user.
Storing SSH keys in an authorized_keys file is the standard way for
SSH to store public keys. Each key is stored on a separate line.
The order of the keys in the file determines the sequence numbers of
the keys.
Invalid keys are marked with the prefix '# INVALID'.
To keep the sequence numbers intact when a key is deleted, a
'# DELETED' line is inserted at the position where the key was
deleted.
Other comment lines are ignored on read, and are not written back when
the file is modified.
Supporting a 2-step live migration for a multi-master Gerrit
installation is not needed since the googlesource.com instances do not
use SSH and there are no other multi-master installations.
On creation of an SSH key, RFC 4716 style keys need to be converted to
OpenSSH style keys. Also before adding a key it should be checked that
the key is parseable. Both of this requires classes from SSH libs that
are only available in the SSH layer. This is why the SSH key creation
must be done there. So far this was done in SshKeyCacheImpl, but since
SshKeyCacheImpl needs VersionedAuthorizedKeys to load keys and to mark
keys as invalid, VersionedAuthorizedKeys cannot not depend on
SshKeyCacheImpl as this would be a cyclic dependency. Instead split
out the SSH key creation from SshKeyCacheImpl into SshKeyCreatorImpl.
This way SshKeyCacheImpl depends on VersionedAuthorizedKeys and
VersionedAuthorizedKeys depends on SshKeyCreatorImpl, and there is no
dependency circle.
Change-Id: I8fcc3c0f27e034fc2c8e8ae3612068099075467d
Signed-off-by: Edwin Kempin <ekempin@google.com>
There was an optimization to not add VisibleRefFilter if all refs of
the project were visible to the calling user, because in this case it
is not needed to evaluate all rules. This optimization is unneeded
because a similar optimization exists within VisibleRefFilter.
VisibleRefFilter checks if all refs except refs/meta/config are
visible to the calling user and if yes only one separate permission
check for refs/meta/config is done.
Removing the optimization for the case where all refs are visible to
the calling user makes this case only slightly slower, since there is
only one additional permission check for the refs/meta/config branch
now. On the other hand the case where a user can see all refs except
refs/meta/config is a little faster now, since the check if all refs
are visible is removed.
By having VisibleRefFilter invoked always, we can now use it to add
magic refs to the advertised ref set, which is e.g. required to
support a magic refs/users/self ref (implemented in the follow-up
change).
Change-Id: Ic8f29b41f3abf23f99b59260956d543f815253cc
Signed-off-by: Edwin Kempin <ekempin@google.com>
The original change Id6c58a595 wasn't ready and broke master.
The revert was I5d56a163; this reverts the revert.
Due to a mistake in a condition in LuceneVersionManager#start()
method writer index was never initialized and thus reindexing
of changes was broken. All tests were still passing because the
tests are using SingleVersionModule and not MultiVersionModule.
This reverts commit 6247b52f4129213c62b93bd7f3e5ce9a32084978.
Change-Id: I5856d3ca2ae6d9549b00aa575abd074ea1ff0bd9
SSH commands are created in request scope. That why it's not needed to
use providers for current user and review db, that are also provided in
the same scope. Providers are needed when data is used across scope
boundaries, e.g. PatchSetParser that is bound in singleton scope must
use providers to access current user and review db.
Change-Id: I53b5d1c4004cd0fbbc6b5f6cdb798b2201e2a9be
In order to be able to filter out non-human comments and votes we need
to tag them.
This change introduces new property to the ReviewInput object called
'tag'. This allows us to add some meta information about where this vote
come from. Then in the UI we can show/hide comments and votes that have
different tags.
Also ApprovalInfo, CommentInfo and ChangeMessageInfo were extended to
include value of 'tag' property read from DB.
To be able to persist those data new column (tag) was introduced to
change_messages, patch_set_comments and patch_set_approvals tables.
Change-Id: If6378c5a9f4e0673c00ab348297549f27a06110b
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Default values are false for boolean, 0 for int and char, and null
for object references.
Explicitly initializing a variable to the default value causes it
to be initialized twice.
Enable the Checkstyle warning, and fix occurences of it.
Change-Id: I1971e438fc506c18458b1402fcb01e43fa61ff8c
CheckStyle reports 'public' being redundant on the constructor of
ApproveOption#Handler, but removing it causes test failures due to
org.kohsuke.args4j.Option requiring an explicitly public constructor.
Add a suppression for that one, and remove the 'public' in other
places where it's reported.
Change-Id: Ifbcf279ffa783d33b81efc1c675f468c3ea39135
enums, interfaces, and field members in interfaces are by default
static, so don't need to be explicitly declared so.
Change-Id: I29270c28be30965767519ad0105a7d93a24e0ab4
Change Ic0e0819b5 added some calls to Throwables#propagate, but I
overlooked that previously existing usages had been replaced in
change Id148cb961 due to intention of Guava to deprecate it.
Change-Id: I90e513c85da4fecbe22679ebbf45badbf3a9edde
When a kerberos principal authenticates with Gerrit using GSSAPI,
the kerberos identity is typically always in lower case. However,
if it is not in lower case, the authentication will always fail
because auth.userNameToLowerCase is not respected.
Teach the GerritGSSAuthenticator to respect the auth.userNameToLowerCase
option to allow mixed-case kerberos principals to authenticate when
this setting is enabled.
Change-Id: I45783e1ebb4b77cacd248afe657559f243ca069d
Signed-off-by: Alex Blewitt <alex.blewitt@credit-suisse.com>
Split out the injected parameters in the counstructor so that they
are on individual lines. Remove `final` in accordance with the
developer guide.
Change-Id: I266be4322be5dbdec32c11948a9bb7f82faf770a
Signed-off-by: Alex Blewitt <alex.blewitt@credit-suisse.com>
There are several places where a new RawInput is created. Factor these
out to static methods in a new RawInputUtil class in gerrit-common.
Inspired-by: David Ostrovsky <david@ostrovsky.org>
Change-Id: I10b099e269427b0f887bfb41bbb3f10f46cf2620
This reverts commit 1762bacf0cab5b2138432032177339a62f502dc7.
This seems to have broken master. New changes are not shown on the
ChangeScreen when pushed. git-bisect indicates that
Id6c58a595086e7dc22cbc7302169d96c4ccf1aa4 caused the problem.
Change-Id: I5d56a1630224242078b2109941adccc6d6d8d721
We now loop over all IndexDefinitions and support online reindexing
for each of them independently. They share the single configured
batch indexing threadpool, so running an arbitrary (small) number of
them shouldn't affect performance more than running one of them.
The markReady implementation still does not correctly respect multiple
indexes; this obviously needs to be fixed before adding any new index
types.
Change-Id: Id6c58a595086e7dc22cbc7302169d96c4ccf1aa4
* stable-2.12:
Add tests for reviewing and submitting refs/meta/config changes
Update 2.11.8 release notes
Prevent NPE in the SshLog
Clear the input box after cancelling add reviewer action
ReviewCommand: Don't add message twice on abandon or restore
Correct schema migration instructions for MySQL in 2.12.1 release notes
Documentation: remove submitted status from user search and review
RebaseChangeOp: adding not null check for PatchSet groups
Set version to 2.11.8
Release notes for Gerrit 2.11.8
Fix keyboard shortcuts for non-US keyboards
Update commons-collections to 3.2.2
Update commons-collections to 3.2.2
Update 2.12.1 release notes
Fix various formatting glitches in the 2.12.1 release notes
Set version to 2.12.1
Update 2.12.1 release notes
Move the logic out of SuggestReviewers and make super class
Submit: Point at problematic other commits in tooltip
Change-Id: Icf745ad1c95e7410ae638cfa9e5f0094541de094
* stable-2.11:
Update 2.11.8 release notes
Prevent NPE in the SshLog
Clear the input box after cancelling add reviewer action
ReviewCommand: Don't add message twice on abandon or restore
Set version to 2.11.8
Release notes for Gerrit 2.11.8
Fix keyboard shortcuts for non-US keyboards
Update commons-collections to 3.2.2
Change-Id: Ieef066a51f72556958be6850276361f4ab526fec
There are 2 types of event listeners: unrestricted, which see all
events, and restricted, which only see the events of a particular user.
The unrestricted listeners are registered using an EventListener
extension point and are held in a DynamicSet. The restricted listeners
were not defined by an extension point, needed to be registered using
the EventSource interface and were held in the instance implementing
that interface. In fact, the EventSource interface only existed to
allow to register restricted listeners. The EventDispatcher is
notifying both type of listeners when an event is posted.
The main motivation for defining EventSource and EventDispatcher
interfaces was to eventually allow a plugin to replace their core
implementations. The problem is, if the listeners are held in the
instance of EventSource provided by the core, they will no longer be
notified when an EventSource instance is loaded from a plugin since all
the listeners will be registered to the wrong instance.
Fix the inconsistency between both type of listeners by removing the
EventSource interface. Create a sub-interface of EventListener called
UserScopedEventListener and expose it also as an extension point.
Now that both type of listeners are held in a DynamicSet maintained by
the core, a plugin will be able to replace the core EventDispatcher.
Change-Id: Ieecb1d6f0ec64d43a0350ec1c133b6ecc189db67
This NPE can happen when command was destroyed (probably by user
canceling the ssh operation) using CommandFactoryProvider.onDestroy
before it was even logged. In this case we provide meaningful audit
entry instead of not-so-nice NPE with stack trace in the logs.
Change-Id: If15a9475a4d98ade9a263b4ed4dcf5a1dd694731
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
When abandoning or restoring a change via the --abandon or --restore
option, and giving a message with the --message option, the message was
being added twice. Once by the 'review' and once by the abandon or
restore.
This was already fixed once in change I9c7e81599 which was included in
Gerrit version 2.6, but was then re-introduced by I2240759ba which was
included in version 2.9.
Fix it, and add an acceptance test to make sure it doesn't get broken
again.
Change-Id: I92f8fd98d75c2b1dd96c91f404be3943109c3519
The Apache Mina project recommends NIO2; since If047c3a2 the sshd MINA
backend is partly broken as well, one more reason to abandon it as
default value.
Using a more stable and recommended backend provides a better
out-of-the-box experience for the new Gerrit installations.
Change-Id: I48c69dd3e6c9c05afe5da35a84c9b2de826e01e6