This change extends the existing cherry-pick endpoints to allow
users to specify the base commit of the cherry-pick destination.
If the base commit represents a visible change revision on the
destination branch, the change status must be either 'New' or
'Merged'.
Alternatively, the base commit can be a merged commit on the
destination branch with no change associated with it.
Change-Id: I6721a2d88f4b73058dc1abf3e85c4184e46088c5
This frees the 'accounts' name so that it can be used for an instance of
the Accounts class in the follow-up change.
Change-Id: Icc3077b4848076a17d3a832f41307abe6de1d87e
Signed-off-by: Edwin Kempin <ekempin@google.com>
The AccountState instance which is held in the account cache contains
the internal groups that the account is member of. Hence the account
needs to be evicted from the account cache when its group memberships
are modified.
Missing to evict the account from the cache leads to failures in
SuggestReviewersIT if SSH is disabled. If SSH is enabled another cache
eviction happens when the SSH key is added, and hence the tests succeed.
Change-Id: I600b7af263d0cd8dcd9c614809f34a0a9a19c895
Signed-off-by: Edwin Kempin <ekempin@google.com>
Previously, we have sent an initial email to CCs added upon push, but
have not persisted them. This change adds logic and tests to do so.
CCs have native support in NoteDb and legacy support in ReviewDb where
they are added as reviewers instead. This mirrors what we do in
PostReviewers and PostReview.
Change-Id: I4177526707141ffe676a5e4db534aeb740b7d53f
* changes:
AccountAccess: Remove unused methods
Let AccountsUpdate take care to evict accounts from the account cache
Let ExternalIdsUpdate take care to evict accounts from the account cache
Do atomic account updates through AccountsUpdate class
Update accounts through AccountsUpdate class
Get accounts through Accounts class
AllAccountsIndexer: Don't load all accounts, but get IDs from user branches
Replace AccountAccess#firstNById(int) by looking at user refs
Remove AccountAccess.anyAccounts and instead check if user branches exist
Prevent creation of non-user branches in All-Users under refs/users/
Disallow creation of user branches
* stable-2.14:
Format Java files with google-java-format
Allow to use AccountCache out of request scope
Change-Id: I016903aa6897c3a000334c7cc758d4caad483fd0
Accounts need to be evicted from the account cache when they are
updated. Instead of leaving this responsibility to the caller let
AccountsUpdate take care of this. This is more convenient and ensures
that none of the callers forgets about it.
Accounts also need to be evicted from the account cache on creation,
since the account cache may hold an empty AccountState instance for that
account ID (if it was requested from the account cache before and was
found missing).
After updating accounts they also need to be reindexed, but this is
automatically done when accounts are evicted from the account cache.
Change-Id: I08d5c756eabd43c29bdc217e7b1c3d85ebf15197
Signed-off-by: Edwin Kempin <ekempin@google.com>
* stable-2.14:
Introduce GlobalPluginConfig{s} annotations
Clarify usage of @GerritConfig#value() and #values()
Clarify usage of GerritConfig#name()
GerritServer: Split annotation sanity check to a separate method
Change-Id: I8c7e145ec4ddacd049f7d908fd74dcf0046c677e
GlobalPluginConfig and GlobalPluginConfigs can be used to annotate
test methods in plugin tests, to provide test configuration values
in $site/etc/plugin-name.config.
The annotations work in the same way as existing GerritConfig{s}, with
addition of "pluginName" parameter.
A limitation of these annotations is that they must be used together
with @UseLocalDisk, so that the plugin configuration files may be
written in the site's etc folder.
Change-Id: I11a66eac87bec5f849858d1a4f38d3f01976ff47
If the value() is given, it takes precedence over values(), i.e.
values() is ignored if value() is specified.
Add Javadoc and a test to clarify this behavior.
Change-Id: I1bf8bd732f973a8d7106601d54680728ad1e0763
Add Javadoc to clarify that the name() parameter of the @GerritConfig
annotation can be used to specify settings like:
[section]
name = value
aswell as
[section "subsection"]
name = value
Also update the tests to use values that make this usage clearer, and
add extra tests to cover the subsection functionality.
Change-Id: Id06d811a26b0127c1bf0540514537b696c457a46
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
* Use URIBuilder, which does proper escaping.
* Use toUriString to properly enclose IPv6 addresses in square brackets.
Change-Id: Ibc4b714010520b098cf8293ce60e1077add2102e
This is the third part of migrating external IDs from ReviewDb to
NoteDb.
This change:
* changes the code to always read external IDs from NoteDb (the
user.readExternalIdsFromGit configuration parameter is removed)
* bumps the database schema version
* deletes the database table for external IDs
Pushing to the refs/meta/external-ids branch is still prevented by a
commit validator. Since all external IDs are now in NoteDb only we
could allow pushing to refs/meta/external-ids. However we would still
like to do validation of the branch content and reject invalid content
(e.g. invalid Git config files, usage of non-existing account IDs
etc.) and such a validator is not implemented yet (but can be
implemented in a follow-up change).
Change-Id: Id9e5574a1d8d82f4f48fbb0b6dadc0e27d138a28
Signed-off-by: Edwin Kempin <ekempin@google.com>
PolyGerrit has a hard time showing the diff view for binary files like
images. To get the base, it has to request it separately using the
parent commit SHA1, which is expensive.
This commit adds a 'parent' parameter to GetContent in the same way that
it is done for DownloadContent. This way, PolyGerrit can use the same
endpoint and avoid expensive permission checks since users who can see a
change are also allowed to see the base commit.
Change-Id: Id6b4d0ea994282d9b4942f9ec1a8f4071a1064b1
* Remove extra blank lines, which is allowed by google-java-format.
* Separate protected from private members and injected from non-.
* Sort lexicographically within groups.
Change-Id: I4e9a192126247b70a43261c70cfa146bb9abc75c
beforeTest assumes that the tempSiteDir has already been created.
Unfortunately, rule evaluation order is arbitrary, depending on runtime
field iteration order. We have been lucky for a long time that
tempSiteDir always got initialized first.
Use a RuleChain instead to express this dependency explicitly.
Change-Id: Ib82071fa3feff3d51cf58f6c61df0ec02ec54a6f
I want to use TestNotesMigration from within InMemoryRepository at the
time the schema is created. The previous approach of calling setFromEnv
from AbstractDaemonTest#beforeTest was too late for this usage. There is
no way to move it earlier in AbstractDaemonTest, because we don't have
the TestNotesMigration until it's injected, which is after the schema is
created.
Instead, move initialization into the TestNotesMigration constructor, so
we never use an uninitialized instance. Keep the setFromEnv
functionality, but call it resetFromEnv. Call it after tests in case
tests have modified the values during tests.
Change-Id: Ib7cdcd97792edf4d278cdaea735a4fbedfd49ca3
Make sure that for every account a user branch exists that has an
initial empty commit with the registration date as commit time. The
commit timestamp of the first commit on a user branch will be used as
registration timestamp when accounts are stored in NoteDb.
When an account is created create the user branch with an initial
empty commit that has the registration date as commit time.
For existing accounts add a schema migration that:
- creates the user branch with an initial empty commit that has the
registration date as commit time if the user branch doesn't exist yet
- rewrites the user branch if it already exists and inserts an initial
empty commit with the registration date as commit time (if such a
commit doesn't exist yet).
Change-Id: I81491a253350a43f094fdfcb32298efde0cb086a
Signed-off-by: Edwin Kempin <ekempin@google.com>
This functionality causes a race during tests that may cause flaky
failures. Specifically, in the case of
ChangeIT#abandonAndRestoreAllowedWithPermission:
1. ACL grant on the main thread (A) modifies refs/meta/config, which
triggers ReindexAfterRefUpdate, which kicks off a background task
(thread B) to search for and reindex affected changes.
2. B reads change from primary storage, observes that it is open, and
constructs a document.
3. A abandons the change, saves the result in primary storage.
4. A indexes the change, deleting it from the open index and adding it
to the closed index.
5. B indexes the document it constructed in (2), adding it to the open
index.
6. A attempts to look up the change, finds it in both the open and
closed indexes, and explodes.
Turning off auto-reindexing causes tests to pass.
The race still exists in running servers, although in practice the
inconsistent cases are fleeting and the index should usually end up in a
consistent state. More details and reflections are in the bug.
Bug: Issue 5944
Change-Id: Ifca5a1065852db38a562755b652fad3de3672816
By moving out the repository registration, we can get the registered URI
which can be used to connect to the repository for both fetch and push.
This makes it possible to clone a remote repository to another remote
repository in the integration test and both of them are managed by
GitRepositoryManager.
Change-Id: Ic941ae184249bb9521da52350ae45b24cfe5f8c9
Within NoteDbBatchUpdate, always use the revwalk, inserter, and
commands from the single RepoView associated with the update. All
BatchUpdateOp#updateChange implementations have been converted to
inspect the limited kinds of repo state exposed by RepoView, so they
will see the results of updateRepo even though the ref updates have not
been executed yet.
One complication comes from the fact that NoteDbUpdateManager really
wants to control execution of the BatchRefUpdates via its own execute
method. We have to make sure the execute method is deferred until after
updateRepo has been called. This requires expanding the previous
ChangeResults returned by executeChangeUps into something a little more
beefy.
Change-Id: Ia5b34bae93630f6d4dbeddb4ad5ce725ba5c6147
Using a simple counter makes it clearer that the generated Change-Ids
are guaranteed to be unique.
Change-Id: I0154bb05ea1969a2684b247ce1661d65591526ad
* stable-2.14:
Add new maintainers to developers section in pom.xml files
Update Version to 2.14-rc0
Change-Id: Ib620c5f49ec5dee1a838c082f74b785689edba71
As a first step AccountsUpdate is only responsible for creating new
accounts. Additional functionality to update accounts will be added
later.
This is another step towards migrating accounts from ReviewDb to NoteDb.
In the end all code that needs to update accounts should use
AccountsUpdate. AccountsUpdate can then take care to update the accounts
in ReviewDb and NoteDb.
Change-Id: I77e3a664e23bfa579da7da7c1e86823e7ad905eb
Signed-off-by: Edwin Kempin <ekempin@google.com>
For this the AccountCreator must support creating accounts without
username.
This reduces the number of places where accounts are created, which is a
preparation step for migrating the accounts to NoteDb
Change-Id: If67aaf2d713b7599e27ba087ac2f83cc99e23376
Signed-off-by: Edwin Kempin <ekempin@google.com>
* stable-2.14:
Prevents 2x stop() calls during IntegrationTest
Add missing documentation of assignee related search operators
Rename StartStopDeamonIT to StartStopDaemonIT
Add integration test to check for thread leaks in sandboxed Daemon tests
Fix intopic predicate with regex
Change-Id: Icea87f9bed4711ee2744e5d2a0127b50297df046
It seems that NoteDB does not manage gracefully the double
invocations of the GerritServer.stop and throws a NPE.
However, that is really a corner case that never happens in
real life; setting the server instance to null prevents
multiple close() invocations on the same server object.
Change-Id: I34da521830ca4caa935c2968c567cc5f4daca44d