35969 Commits

Author SHA1 Message Date
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
James E. Blair
0f1eb1d5e7 Set XSRF on '/' under PolyGerrit
A XSRF token is normally set when a user requests one of the
polygerrit index paths (one of which is '/').  The GWT UI
handles setting the cookie on /, so that case wan skipped.

If a user visits /login/ they will be redirected to / after
logging in, which, if PolyGerrit is used, would cause the XSRF
cookie not to be set, which would cause subsequent POST or PUT
operations to fail.

The default sign-in link is to the current page, so typically a
user would end up redirected to /q/status:open and would therefore
end up with a cookie.  However, if the user directly visited
/login (or a site enforced authentication by redirecting there),
they would observe the problem.

To correct this, set the cookie on / if the GWT UI is disabled.

Bug: Issue 10281
Change-Id: I79ad22395ca9d83d0a6fb0785929943d7ae0c186
Co-Authored-By: Michael Burns <mbx@google.com>
2019-08-27 11:14:17 +00: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
Tao Zhou
a25a84c0ee Remove deleted rules for the new added section
Bug: Issue 11339
Change-Id: Ief0944afe03c55a3ee48b7ed23a3997c569b3354
(cherry picked from commit 324adea67bae59918a1c32220dbaaa524325765f)
2019-08-27 09:36:32 +00:00
Ben Rohlfs
e91504ef8c Merge "Use base url for commentlink" into stable-2.15 2019-08-27 07:12:54 +00:00
David Pursehouse
2cfb6c80d0 AccountIT: Test that account is not created with invalid email
Change-Id: Id8040067ce4acffa11280f3c697b9ddb28eec075
2019-08-27 14:24:46 +09:00
David Pursehouse
b5d2b319da CreateAccount: Fail early when invalid SSH key is given
If an invalid SSH key was given, the request would fail only after
the account was already created.

Move the addition of the SSH keys to earlier in the process, so that
if it is invalid the request fails before the account is created.

Bug: Issue 11363
Change-Id: I474f2d7125c13057c57236142c841515cc22c3ea
2019-08-27 14:18:47 +09:00
David Pursehouse
eca3a9db67 Update git submodules
* Update plugins/replication from branch 'stable-2.16'
  to 896e67184e9b98262775ab1c71a0b76ac5baff21
  - ReplicationIT: Don't swallow exceptions on failed repository operations
    
    The methods getRepo and getRef catch exceptions and return null, which
    will then cause NullPointerException on subsequent dereference, making
    it less easy to track down the actual cause.
    
    Remove the getRepo method and always open the repo in a try-with-resource
    that will throw the exception and fail the test if the repository could
    not be opened.
    
    Some calls to getRef are done in a consumer which means the method can't
    throw an exception. In these cases, it's OK for the method to return
    null because then the test will fail anyway due to InterruptedException
    being raised when the non-null was not returned within the timeout.
    
    Other callers of getRef however should not get the null value as it will
    cause NPE.
    
    Make getRef throw the exception, thus failing the test early, and add a
    variant method "checkedGetRef" which returns null and is used in the
    consumer.
    
    Also replace usage of printStackTrace with FluentLogger.
    
    Change-Id: I0f0caca03386c4fa5710f4c8e8fd4f798acead2b
    
  - ReplicationIT: Add explicit test for replication of new branch
    
    Change-Id: I67aa8b4aec05ad23b3c286d56a3b894eede7cd7e
    
  - ReplicationIT: Change test method name to reflect actual operation
    
    The test shouldReplicateNewBranch creates a new change and then
    verifies that the corresponding refs/changes/xx/yy/zzzzzz ref is
    replicated to the destination.
    
    Rename it to shouldReplicateNewChangeRef to match what it's actually
    doing.
    
    Change-Id: I32fe7237c8857907dd51d627a571f6ccb73741a3
    
  - Allow AdminApiFactory to be replaced dynamically
    
    Since change Ie760bf3e1 the GerritSshApi class is no longer a singleton,
    and is instead instantiated on demand by a new AdminApiFactory.
    
    This breaks implementations that consume the replication plugin as a
    library and extend the GerritSshApi, since the extended class no longer
    gets instantiated in place of GerritSshApi.
    
    Refactor it so that AdminApiFactory is an interface with a default
    implementation that gets bound as a dynamic item, which can be replaced
    by derived implementations.
    
    Change-Id: Ia150d6802e11015fa00ee9144b3dfbfa696c7a0d
    Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2019-08-27 05:00:53 +00: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
David Pursehouse
615c5be25b ProjectState: Fix 'invalid type qualification' javadoc warning
Change-Id: Ib7f7442e277d034f55e6281482bb93e61f4b879c
(cherry picked from commit 07f8abf65e9bb575898de403a273a1a92b9263d5)
2019-08-27 09:40:33 +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
Paladox none
0a80c90639 Use base url for commentlink
Bug: Issue 11344
Change-Id: I68aa21f81e88441f01b9386fdbf77fbb93810ec3
(cherry picked from commit 8e7bde0da1878cd5f9f62ace8319eb9fb44602c9)
2019-08-26 14:20:57 +00:00
Paladox none
573f2b9431 Merge "Upgrade highlight.js to latest master revision" into stable-2.16 2019-08-26 12:59:14 +00:00
David Pursehouse
dea5811387 Update git submodules
* Update plugins/replication from branch 'stable-2.16'
  to 86b3ac835c651cbaff0c0dd9b2540ceee4c32a78
  - Fix test build rule to include *IT tests
    
    The glob in the build rule only includes *Test.java files, thus the
    recently added ReplicationIT was not being executed.
    
    Update the rule to include *IT.java files.
    
    Change-Id: I04a76723feb6e38dd441b41e9de22e5fdf1c4578
2019-08-26 11:50:22 +00:00
Patrick Hiesel
171ff5f238 Don't store LabelTypes in ProjectState
ProjectState is only invalidated if the underlying config changes, but
not when any of its parent's config changes. Therefore it must not
store any data locally that it derived from any parent.

Bug: Issue 11248
Change-Id: I3f8d74e829274701c54d5898f6348971a59f866f
2019-08-26 13:50:17 +02:00
Paladox none
8b24007ac9 Upgrade highlight.js to latest master revision
Update is from commit 52925a627f20cbc28bc4eaeffd1824244e6e895d

Includes a fix for Issue 11350.

Adds support for custom css properties.

Adds support for html`` syntax in js.

And some more fixes.

Bug: Issue 11350
Change-Id: I7e5d82697cc5bf506ed2864611fed866d0ff1007
2019-08-26 11:10:56 +00:00
David Pursehouse
e3cbbad2e1 Merge "Upgrade JGit to 5.1.10.201908230655-r" into stable-2.16 2019-08-26 10:57:51 +00:00
Luca Milanesio
635eb1483c Update git submodules
* Update plugins/replication from branch 'stable-2.16'
  to 4ed1a3eaa052672422f5f19468736de42e4d4d27
  - ReplicationIT: Do not use deprecated getRef()
    
    Change-Id: Idf56bcb4d9e7ed514d1011f62d6738d124ba870a
2019-08-26 10:02:17 +00:00
Edwin Kempin
fd57b4123b Merge "Merge branch 'stable-2.15' into stable-2.16" into stable-2.16 2019-08-26 07:10:38 +00:00
Luca Milanesio
5a5f168523 Update git submodules
* Update plugins/replication from branch 'stable-2.16'
  to d5170016dbb9db03f686c2a6f4994295b685aeb8
  - First ReplicationIT test for new project and change
    
    Test end-to-end that a new project and a new change are propagated
    to the replicated repository.
    
    Change-Id: Iea4170aa881757c7e29bc6237fe4c230da8ae0ec
2019-08-26 05:46:11 +00:00
Luca Milanesio
811ba81adb Update git submodules
* Update plugins/replication from branch 'stable-2.16'
  to 24ae8627fef3aef243e8e22c30901617f724ad4c
  - Revert "Delete event file only after replication completed for all destinations"
    
    This reverts commit d557ccc642c59a55750f560ce0d98870e1550d65.
    
    Reason for revert: This fix did not solve the problem, see associated issue.
    
    Bug: Issue 11172
    Change-Id: Ifc2e7209bd86163e945f0595ff0ebd681932053f
2019-08-26 05:45:57 +00:00
David Pursehouse
faf30c51fc Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
  Upgrade elasticsearch-rest-client to 7.3.1
  Add .gitreview file

Update the newly added .gitreview file to point to stable-2.16.

Change-Id: I9ca52ec3d90dea1b44321be4eb648448abafff1e
2019-08-26 09:32:16 +09:00
David Pursehouse
8e8bd2b669 Upgrade elasticsearch-rest-client to 7.3.1
Also update the test container to use this version for V7_3 tests.

Change-Id: I2b1913f355101c10649477222beed84fccbc3961
2019-08-26 08:50:23 +09:00
Monty Taylor
78f5bf3b85 Add .gitreview file
For folks used to using the git-review tool for interacting with
gerrit servers, it's necessary to have a .gitreview file in the
repo in question pointing to where the gerrit is.

Add one, pointing at gerrit-review.googlesource.com and listing that
https should be used. This will still require that someone add their
http authentication to the .gitcookies file, but otherwise should
work as expected.

Set defaultbranch to stable-2.15 so that patches will be submitted
to refs/for/stable-2.15.

Bug: Issue 9450
Change-Id: Iace9ed4f94441d2fd5cbb1f95eb69f135981836f
2019-08-25 17:05:21 +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
Luca Milanesio
21c8de76ff ChangeIT: set submittableAfterLosingPermissions private
submittableAfterLosingPermissions() is just used internally and
thus should be private.

Change-Id: I84d29b1fa864f274a9f4455a073fef8723eef3a2
2019-08-24 16:56:54 +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
Edwin Kempin
e4d1b55a1a Rebase: Don't swallow caught exception
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ie485ec39ae7acc2863823fefa39494475c302079
2019-08-22 19:00:44 +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
fa4840be35 Update git submodules
* Update plugins/replication from branch 'stable-2.16'
  to bc9c7eaca297578e2e86e961118336a72227ac87
  - GerritSshApi: Consistently use logError method
    
    Change-Id: I9aeb27ce9e535c177fcdab3bee417c77233e8310
    Signed-off-by: David Pursehouse <dpursehouse@collab.net>
    
  - GerritSshApi: Make sshHelper and uri members protected
    
    This allows them to be accessed by classes that extend GerritSshApi.
    
    Change-Id: Ie2ca2da1303ed4a14ac6074e37696c5f509f3ebe
    Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2019-08-22 07:42:55 +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
Edwin Kempin
aefd1d5c27 StarredChangesUtil: Fix NPE when ref to be deleted doesn't exist
When deleting star refs on a change deletion the star refs are computed
from the index which may be stale. If the ref that we want to delete
doesn't exist that's fine and we can just skip it.

This NPE was observed when a change deletion failed with LOCK_FAILURE
and then the request was automatically retried.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Icb73fdfd5bf6141176b733a25809c59e7f4d5c22
2019-08-22 09:47:01 +09:00
Edwin Kempin
7911c2caba StarredChangesUtil: Throw LockFailureException on LOCK_FAILURE
In case of a LockFailureException we automatically retry the ref update,
however when the deletion of star refs failed with LOCK_FAILURE we threw
a normal IOException which was treated as non-recoverable failure.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I3a557c725eb43eb12ae60329ccc0cbda4560459a
2019-08-22 09:46:14 +09:00
Edwin Kempin
f42b79c575 Add test for creating a change on a non-existing base change
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: If933195e5bff60deb7ff7b7748bbe66bb80686d0
2019-08-22 09:44:16 +09:00
Edwin Kempin
266d9074cd Rebase: Do not fail with 500 ISE if non-existing change is given as base
If the specified base change is missing we should rather return
422 Unprocessable Entity.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ic619e2ea80ee9a16c70693cebc2160682da298b7
2019-08-22 09:42:00 +09:00
Edwin Kempin
f4e432bfc8 Fix detecting changes of parent trees when computing change kind for merge commit
A new patch set of a merge change is considered as NO_CHANGE if the
commits have the same delta and trees. For merge commits this includes
comparing the trees of the parent commits.

The comparison of the trees of the parent commits was broken, since we
forgot to parse the parent commits before accessing their trees. If a
commit is not parsed the tree information is not available and the
getTree() method returns null. Since Objects.equals(null, null) returns
true, we wrongly assumed that the parent trees didn't change. Due to
this new patch sets of merge changes were detected as NO_CHANGE even if
the tree of the second parent was changed.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ib4ea0501bf5674e479f23510d8e2ceadcb025c3d
2019-08-22 09:28:18 +09:00
Edwin Kempin
89c2b0ddc3 Remove duplicate descriptions of fields in Requirement JSON entity
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I513da3ba0e1c2c44e078721afeb483976b971ad9
2019-08-22 08:59:17 +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
324e61b4b4 Set version to 2.16.11-SNAPSHOT
Change-Id: I81a1574a77e303c38e7ed6e80a95dcf0e82e2adf
2019-08-16 11:48:53 +09:00
Ben Rohlfs
067d06161a Merge "Upgrade Go Bazel rules to the latest version" into stable-2.16 2019-08-14 10:52:54 +00: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
09f5f3bc81 Merge branch 'stable-2.14' into stable-2.15
* stable-2.14:
  Revert "Migrate from old-style legacy .java provider to the new JavaInfo."
  Catch all exceptions for reporting on Schema_130 migration

Change-Id: I06688c3e2f51daead715e232186d74d4fc7fcdf6
2019-08-14 15:05:44 +09:00
David Pursehouse
3edd41d55c Revert "Migrate from old-style legacy .java provider to the new JavaInfo."
As a result of this change the contents of the war file are different,
for example the postgresql library:

Before:
  WEB-INF/lib/postgresql-42.2.5.jar

After:
  WEB-INF/lib/libpostgresql.jar

This causes the initialization of the site to fail when using the
postgres DB:

  fatal: Driver class org.postgresql.Driver not available
  fatal: Cannot connect to SQL database

This reverts commit c928ec3adc3286bf740d5c97b6ef0368ce29ee6a.

Change-Id: I3fd0695f12c87fe4a049ee30739ef8674b587c6e
2019-08-14 12:56:13 +09:00
Luca Milanesio
3aca363032 Catch all exceptions for reporting on Schema_130 migration
When migrating all projects configs during Schema_130 migration,
any unexpected exception would not show the name of the impacted
repo, causing a headache for the Gerrit admin that is willing to
migrate.

Make sure the impacted repository and the exception caused are
always displayed so that the Gerrit admin can have an easier
life understanding what happens.

Change-Id: I133c435d9e6d8677964102b26740d55d687764c6
2019-08-13 08:18:53 +01:00