2518 Commits

Author SHA1 Message Date
Marco Miller
91692f83c9 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Add support for Elasticsearch version 7.4.*

Change-Id: Ic9bc8e16fc40e03e115c4a649fc3b4026ce1069a
2019-10-07 12:57:05 -04:00
Gert van Dijk
3830074304 Init: do not overwrite httpd.listenUrl until the input has been validated
Before this change, when using init in interactive mode and the input was
invalid for the HTTP daemon settings (e.g. invalid 'host'), init would
fail with a fatal error, but the invalid configuration string would still
be written to the configuration file.

Change-Id: Icf5d864b61443c13bcc6a90c766b16cc908052d5
2019-09-30 11:09:32 +09:00
David Pursehouse
d604d2cedb Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  MergeOp: Fix swapped message and tag parameters for ChangeMessage
  Documentation: rewrite httpd.listenUrl

Change-Id: Ia11ddea20b9dd2150f8aad815a253ab61fccb97e
2019-09-30 11:05:20 +09:00
Luca Milanesio
91180b417e AccountManager: Allow to duplicate emails per account
Fix a recurring issue after the migration of external ids from ReviewDb
to NoteDb failing with the error 'Email <email> is already assigned to
account <>' and thus failing LDAP authentication.

The LDAP authentication may or may not have generated the preferred
email record in the main 'gerrit:<>' account. Consequently, users may
have added their external id as additional 'mailto:<>' record. That
was a normally supported use-case and, previously in v2.15, did not
create any problems or conflicts.

Starting with v2.16 the extra check for unique e-mails did go a bit too
far and blocked the ability to have both the 'mailto:' record and having
the same value also as preferred e-mail, which is incorrect because it is
a perfectly valid use-case (see Change-Id: Ie4c677365cd).

When linking or updating the preferred e-mail to an existing account,
accept duplications only if both external ids belongs to the target
account id. Because both e-mails (preferred e-mail and 'mailto:' record)
belongs to the same account, they are not really duplicated but just a
legacy of the way Gerrit was used to indicate an external 'mailto:'
identity that has been selected as primary e-mail afterwards.

Add unit-test that consistently reproduce the issue that many people
have reported after having migrated the accounts and external-ids to
All-Users.

NOTE: Even though the issue has been reported on the LDAP authentication
use-case, the problem lies in AccountManager and is more generic.

Fix the consistency checker for the e-mail external ids when
multiple duplicate entries are associated with the same account.

Bug: Issue 11246
Bug: Issue 9001
Change-Id: I78bc82faa2761bc0e56a9fa54a94225c82317275
2019-09-28 15:42:41 +02:00
Thomas Draebing
dbbe888f5f Fix plugin's capabilities to allow creation/deletion of data
If a user had a capability added by a plugin, e.g. in case of the
serviceuser plugin to create a service user, but was not an
administrator, modifying a resource was failing. The error involved was:

  com.google.gerrit.server.permissions.PermissionBackendException:
    cannot extract permission

This error was caused, since the plugin name was not set in the viewData,
when the capabilities were checked in case the view was
a child RestCollection.

This change sets the plugin name in the viewData to the value of the
parent view instead of setting it to `null`.

Bug: Issue 11374
Change-Id: Ia679367216cf8898b60445a1290b9ac5b1f56b25
2019-09-20 15:02:38 +00:00
David Ostrovsky
0326b5dd14 SshDaemon: Install unknown channel reference handler
Since SSHD 1.7.0 unknown channel reference should be provided, otherwise
session can crash, see this SSHD issue for more details: [1].

[1] https://issues.apache.org/jira/browse/SSHD-942

Bug: Issue 11491
Change-Id: Ic3d5f86ead0cf9669a3d73d6822ccd8b86114607
2019-09-20 16:58:51 +02:00
Saša Živkov
3372cd1816 Merge "Allow admins to index a change even if the branch is not Readable for them" into stable-2.16 2019-09-13 08:22:49 +00:00
Sven Selberg
ad38bbb299 ReviewDbBatchUpdate: Avoid NPE when updating All-Users
If one change-update in a batch affects All-Users it is assumed that
all ChangeTasks updates NoteDb. This is not true when a stack of
changes is pushed and the changes(s) at the bottom of the stack are not
updated, existing last patchset is pushed.

Bug: Issue 11442
Change-Id: I0c828635920cc437da3da20785d3882a2e68d086
2019-09-12 16:17:28 +02:00
Saša Živkov
e922306384 Allow admins to index a change even if the branch is not Readable for them
The ChangesCollection rejects the request if the current user doesn't have the
Read permission on the loaded change. Therefore, an attempt to reindex a change:

  PUT /changes/myProject~12345/index

gets rejected even before it reaches the indexing code.

On the other side, the admin can reindex all changes of that project and thus
also index the change 12345:

  POST /projects/myProject/index.changes

Indexing all changes of a project in order to just index one change is too much.
Add a new REST endpoint where a set of change-ids to index is given in the
request body.

  POST /config/server/index.changes
  Content-Type: application/json; charset=UTF-8

  {changes: ["foo~101", "bar~202"]}

Bug: issue 11205
Change-Id: I05fcc5a024c7634a969a7baac9fd61f3d0f3d12a
2019-09-11 14:39:51 +02:00
David Pursehouse
4eb25d1cca Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Format BUILD files with buildifier
  Format BUILD files with buildifier
  junit.bzl: Fix name conventions warning flagged by buldifier
  Bazel: Avoid using tools in action inputs
  dev-contributing: Update recommended version of buildifier to 0.28.0

Change-Id: I20579e30a97b640d23df38e2bf129fea0003c548
2019-09-09 08:22:58 +09:00
David Pursehouse
632b5b0f4c Merge "Convert NoteDb migrator output into chars" into stable-2.16 2019-09-04 23:20:22 +00:00
Luca Milanesio
4b64e05d14 Convert NoteDb migrator output into chars
Fix the NoteDb migration progress by converting its binary output
into printable characters that can be easily understood by humans.

Bug: Issue 11444
Change-Id: I6c2c6f036d8e5402ce72b7cdd53a4677b0f54521
2019-09-04 23:05:31 +01:00
Matthias Sohn
69d4ad47d6 Revert "Revert "GerritServer: Silence non-critical logs from JGit's FS""
This reverts commit 7e072d129acf7219521c2a2f7334907e45da4adf.

Change-Id: I5569358cd673144eb4fae4a5fdaf5bbddc3b1cb6
2019-09-04 18:56:55 +02:00
Matthias Sohn
98f442a828 Revert "Revert "GerritServer: Silence non-critical logs from JGit's FileSnapshot""
This reverts commit 6dba3ba183bce26be0bdf8095b3e9ce3e058612d.

Change-Id: I61733b44ba710a986a746b0502ff8c1b5a4eb2f0
2019-09-04 18:56:54 +02:00
Matthias Sohn
064f0597e3 Revert "Revert "Stop using deprecated DirCacheEntry#setLastModified(long)""
This reverts commit dd382e8ac9eb7287060a6dfde5227982cff8b888.

Change-Id: Ia2dda0461a99cc3f023e34902ca1c5424904d215
2019-09-04 18:56:54 +02:00
David Pursehouse
31c82401f0 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Bazel: Add fixes for --incompatible_load_{java|python}_rules_from_bzl
  Bazel: Bump minimum supported version to 0.29.0
  Lucene index configuration and docs.

Change-Id: I6c597cbc89fafece83c374e9b36c4c4c0126704f
2019-09-04 16:35:55 +09:00
David Pursehouse
ff43d4f05d Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Set version to 2.15.17-SNAPSHOT
  Set version to 2.15.16
  Revert "CreateAccount: Fail early when invalid SSH key is given"
  tools/eclipse/project.py: Fix typo of bazelisk
  Migrate from old-style legacy .java provider to the new JavaInfo.
  Support bazelisk or bazel in tools/eclipse/project.py
  Rework imports in project.py
  Update project.py to use argparse

Change-Id: If9388140c516f8ff2f5275eefe6cf65dad42449e
2019-08-29 08:16:50 +09:00
David Pursehouse
6dba3ba183 Revert "GerritServer: Silence non-critical logs from JGit's FileSnapshot"
This reverts commit bd68b579e87736977df26bb6ef6a1649b635577f.

Reason for revert: Not needed after JGit update was reverted.

Change-Id: I6a27c05e7078d6874db66e1c0919622748e5bf75
2019-08-28 17:58:26 +00:00
David Pursehouse
7e072d129a Revert "GerritServer: Silence non-critical logs from JGit's FS"
This reverts commit 0d025efd4b644bbc2d9368bac5d8f353dd9f5d75.

Reason for revert: Not needed after JGit update was reverted.

Change-Id: If26d672dd3f09f5ff25540ad90128e1edd08ee41
2019-08-28 17:58:17 +00:00
David Pursehouse
f44239c369 Revert "Upgrade JGit to 5.1.10.201908230655-r"
This reverts commit 13f55abe3c26662634f72499ffc88d725f7c1292.

Reason for revert: The upgrade broke OnlineNoteDbMigrationIT.

Bug: Issue 11373
Change-Id: I8191456cafd8e670a0e38e98bca0efde752419ff
2019-08-28 17:58:07 +00:00
David Pursehouse
dd382e8ac9 Revert "Stop using deprecated DirCacheEntry#setLastModified(long)"
This reverts commit cba560d1fc26e7d757a28596a1d292537dec21fc.

Reason for revert: The Jgit upgrade that made it necessary is
being reverted.

Bug: Issue 11373
Change-Id: I372023a611cfe02adc38827ceb6a66b5f9a67ce0
2019-08-28 17:57:59 +00:00
David Pursehouse
41dcad8cc5 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Set XSRF on '/' under PolyGerrit

Change-Id: Ia3da453253c84a8e04fce42f188dbcb700da0b1e
2019-08-27 21:12:16 +09:00
David Pursehouse
aacff85663 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  AccountIT: Test that account is not created with invalid email
  CreateAccount: Fail early when invalid SSH key is given
  Use base url for commentlink

Change-Id: Ifac43208ba54ffcc012e1ff9374272466555bfbc
2019-08-27 19:55:21 +09:00
David Pursehouse
0d025efd4b GerritServer: Silence non-critical logs from JGit's FS
Change-Id: Id2c96d3f39625548e945b27fb55ac8fa493f5954
2019-08-27 11:27:41 +09:00
David Pursehouse
bd68b579e8 GerritServer: Silence non-critical logs from JGit's FileSnapshot
In JGit 5.1.10.201908230655-r additional debug logs were added in
the FileSnapshot class, and these cause a lot of unwanted messages
when running tests.

Set the log level to WARN for this class.

Change-Id: Ie8dba4fd17e59ae5d49730f36f1b5f06f83b17d1
2019-08-27 11:20:20 +09:00
David Pursehouse
cba560d1fc Stop using deprecated DirCacheEntry#setLastModified(long)
Since [1], which is included in JGit since 5.1.10.201908230655-r, the
method DirCacheEntry#setLastModified(long) is deprecated in favor of
DirCacheEntry#setLastModified(Instant).

Replace the only usage of the deprecated call with the new one.

[1] https://git.eclipse.org/r/#/c/145437/

Change-Id: I7c87b20d518ad68652d2f91317d6a4505df21fe4
2019-08-27 09:41:32 +09:00
David Pursehouse
34a6e23415 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  ProjectState: Fix 'invalid type qualification' javadoc warning

Change-Id: Iaa88f0007ec18cfa41025f74eb5ac4d11ffa01d5
2019-08-27 09:41:21 +09:00
Antonio Barone
2d6e438053 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Don't store LabelTypes in ProjectState

Change-Id: I4c9b1b6347ba3ca935292c053490c42c2d3bf8d5
2019-08-26 16:23:12 +02:00
Matthias Sohn
13f55abe3c Upgrade JGit to 5.1.10.201908230655-r
Improvements in 5.1.9 and 5.1.10:
- measure FileStoreAttributes per filesystem
  - improve measuring file timestamp resolution
  - measure minimal racy interval
  - use Instant to increase resolution to 1us (limited by FileTime)
  - persist FileStoreAttributes
  - optional asynchronous measurement of FileStoreAttributes
  - directory - FileStore cache
- cache user and system level gitconfig
- fix supportsAtomicCreateNewFile default to true
- fix non-deterministic hash of archives created by ArchiveCommand

Release notes:
https://projects.eclipse.org/projects/technology.jgit/releases/5.1.9
https://projects.eclipse.org/projects/technology.jgit/releases/5.1.10

Change-Id: Ifc110f1f305d16cb7f3c2dbe55e3b4855c1b7ce1
2019-08-25 04:57:17 +00:00
Luca Milanesio
16a6eeb825 DeleteDraftComments: Don't update change modified timestamp
When removing all the changes associated with a user,
do not bump the associated updatedOn timestamp similarly
to what it does the single removal of individual drafts.

Add also coverage for the existing use-cases where
adding or removing a draft change should not update
the updatedOn timestamp, already working but not properly
covered.

Bug: Issue 11325
Change-Id: Ieaad3888b570db9eee6e2eb8130acc3b4cfe3d16
2019-08-24 23:05:18 +00:00
David Pursehouse
7b7fe5fe65 Merge "Output NoteDb migration progress to Flogger" into stable-2.16 2019-08-22 10:49:15 +00:00
David Pursehouse
5f78e60775 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Rebase: Don't swallow caught exception

Change-Id: I9d4cd56d6b4a7e2ec612e4e401b77b8e1bf73b99
2019-08-22 19:02:17 +09:00
Luca Milanesio
001694bd21 Output NoteDb migration progress to Flogger
Allow to track the progress of the conversion to
NoteDb by sending the progress output to Flogger
instead of throwing it away.

This allows Gerrit admins to keep track of the status
of the migration to NoteDb and predict the ETA of the
conversion completion.

Bug: Issue 11348
Change-Id: I398a118c966faebab64c0dfa718ee268191eae5c
2019-08-22 09:01:23 +00:00
David Pursehouse
a0fa8af831 DefaultChangeReportFormatter: Make constructor and urlFormatter visible
Implementations may want to only change the default for some of the
ChangeReportFormatter's methods, in which case it makes sense to
extend the default implementation. However this is not possible when
its constructor is private.

Likewise, extending classes might need to use the UrlFormatter instance.

Make the constructor public and the UrlFormatter protected so that they
are visible to deriving classes.

Change-Id: Ia4a24f29e0d283cad40b1f90d019ea7f65bc0cb2
2019-08-22 14:16:22 +09:00
David Pursehouse
c65db0ee1d Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  StarredChangesUtil: Fix NPE when ref to be deleted doesn't exist
  StarredChangesUtil: Throw LockFailureException on LOCK_FAILURE
  Add test for creating a change on a non-existing base change
  Rebase: Do not fail with 500 ISE if non-existing change is given as base
  Fix detecting changes of parent trees when computing change kind for merge commit

Change-Id: I8ec9c55d86c3b425e0bce289f4c92cd5b6adbc80
2019-08-22 10:57:32 +09:00
David Pursehouse
630dcde3a0 InternalAccountQuery: Add back the oneByExternalId method
Change I45ccec5ed removed several methods from InternalAccountQuery
that are no longer used in core Gerrit. One of them, however, is
used in CollabNet's integration.

Add back the method that is used, and annotate it with @UsedAt.

Make adaptations compared to the original version that was removed:

- Use the FluentLogger rather than slf4j's Logger
- Use the Stream API rather than Guava's Lists.transform

This partially reverts commit 69f297f568aa3648df1096aba08eac387ef7e28d.

Change-Id: I9170932646960754ef2ec4b9287d7c71844403a2
2019-08-16 19:38:30 +09:00
David Pursehouse
c84140787e Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Revert "Migrate from old-style legacy .java provider to the new JavaInfo."
  Catch all exceptions for reporting on Schema_130 migration
  Migrate from old-style legacy .java provider to the new JavaInfo.

Change-Id: I8fe109677bfa32c4fccceef28ff234d666d90c24
2019-08-14 15:06:36 +09:00
David Pursehouse
bc228f5e3d AuthRequest: Fix Javadoc for return values
The methods' javadocs state that the return is 'null', but this was
changed some time ago to be Optional.empty().

Change-Id: I8f883cf7d79efb848d70043d23ecc707cfcdf1d0
2019-08-12 14:49:08 +09:00
David Pursehouse
8450917187 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  ChangeApi: Add methods to get change comments/drafts as list
  ListChangeComments: Extend ListChangeDrafts
  detach -> detached
  Fix anchor tag for settings page

Change-Id: Id9f3cf0b5ec13ac38f6f011c611c5096f622c1aa
2019-08-12 10:21:37 +09:00
David Pursehouse
6a9e86509c Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Add support for Elasticsearch version 7.3.*

Also update ElasticV7QueryProjectsTest to use V7_3.

Change-Id: Ib7081c5b15756e2ca91d448430928b2f5b8aca50
2019-08-06 16:07:44 +09:00
David Pursehouse
66e4a6baea Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  PrologEnvironment: Reduce "setting reductionLimit" log spam

Change-Id: I25166766abbf7425498e349b38e1100589623bef
2019-08-06 13:36:31 +09:00
David Pursehouse
debef82914 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  ElasticContainer: Upgrade to 6.8.2 image for V6_8 tests
  Fix typo: program
  Clarify usage of 'parent' option in list files API
  Remove unused Skylark patch file
  Files: Use Gerrit API to get revision parents
  Add support for Elasticsearch version 6.8.x
  Upgrade elasticsearch-rest-client to 7.2.1
  CommitApi: Add method to get commit info
  Consolidate all CommitApi tests into a single class
  Files: Validate parent option to prevent internal server error
  RevisionIT: Assert that files(base) only works for patch set revisions
  Fix and expand documentation of REST API to get revision files
  RevisionIT#files: Simplify assertion
  Update git submodules

Also update ElasticV6QueryProjectsTest to use V6_8.

Change-Id: I98da65486f39acad509529ff90540d9f8ae00a2d
2019-08-05 10:13:00 +09:00
Marco Miller
040b8a19a0 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  HashtagsInput: Add a constructor allowing to initialize remove member

Change-Id: I0362c2133b1e9782eb676a72c7346837a5623220
2019-07-30 17:04:08 -04:00
Luca Milanesio
d2a9ad8ead Fix ls-user-ref and use the correct identity for listing refs
The ls-user-ref was broken by Change-Id: I1819de0bab where
the refactoring of the permission backend needed to be passed
the current user as parameter. As a result, the LsUserRefs, started
using the user's identity executing the command instead of the one
requested as a parameter.

Bug: Issue 11235
Change-Id: I48b6e14a2fe24d3d2a96a8274bd9e0108dc0c95d
2019-07-25 16:34:48 +00:00
Marco Miller
9f1ab6a46b Merge "change-merged: set correct newRev on submit by push" into stable-2.16 2019-07-25 15:06:16 +00:00
David Pursehouse
cfa98404cb Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  ReceiveCommits: Fix comparison to ensure correct log message
  Set sshd.threads to at least 4.
  Add assertThrows method compatible with future JUnit 4.13
  ReceiveCommits: Bypass commit count when skip-validation is used
  Update git submodules
  Update git submodules
  Update git submodules
  Update git submodules
  Update git submodules
  Update git submodules

Change-Id: Iea0dc2d5f28c0c8e0489e7ce2bb429064ce7aca3
2019-07-25 12:33:37 +09:00
Edwin Kempin
0f6f21c916 AccountCacheImpl: Don't return null on error but Optional.empty()
Callers do not expect that methods that return an Optional may also
return null.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I1962891693aaa9048771f5f7eae7c303a826da13
2019-07-16 10:46:23 +00:00
Sven Selberg
77df787ce5 change-merged: set correct newRev on submit by push
Bug: Issue 11083
Change-Id: I12acf29549c35c93219867348c3691a24415e28c
2019-07-15 22:41:26 -04:00
Edwin Kempin
bb40fe23c8 Fix input object of IndexChanges REST endpoint
This REST endpoint shouldn't accept any input, but it was wrongly
accepting a ProjectInput (which is used by the Create Project REST
endpoint to specify the properties of a new project).

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Iaada3114e11dccba474f3e26101017a576998b79
2019-07-14 11:51:31 +09:00
David Pursehouse
7b856b1834 Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Expose Gerrit's GWT client library in the plugin API
  Replace usage of Iterables.limit with Java 8 Stream API
  Follow up to "Adapt gerrit.sh script to work on Alpine Linux"

Change-Id: If66c0dd7f912e4551a6855c3cf299ed2586873dc
2019-07-13 10:30:36 +09:00