diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index af0daf4722..fb5bc153b4 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -482,6 +482,16 @@ editing gerrit.config and restarting the server. + Default is true. +[[auth.allowRegisterNewEmail]]auth.allowRegisterNewEmail:: ++ +Whether users are allowed to register new email addresses. ++ +In addition for the HTTP authentication type +link:#auth.httpemailheader[auth.httpemailheader] must *not* be set to +enable registration of new email addresses. ++ +By default, true. + [[cache]] === Section cache @@ -3177,16 +3187,6 @@ and all other properties of section sendemail are ignored. + By default, true, allowing notifications to be sent. -[[sendemail.allowRegisterNewEmail]]sendemail.allowRegisterNewEmail:: -+ -Whether users are allowed to register new email addresses. -+ -In addition for the HTTP authentication type -link:#auth.httpemailheader[auth.httpemailheader] must *not* be set to -enable registration of new email addresses. -+ -By default, true. - [[sendemail.connectTimeout]]sendemail.connectTimeout:: + The connection timeout of opening a socket connected to a diff --git a/Documentation/dev-buck.txt b/Documentation/dev-buck.txt index 21cf4c805e..0cd5e846f0 100644 --- a/Documentation/dev-buck.txt +++ b/Documentation/dev-buck.txt @@ -383,62 +383,6 @@ that artifact: ) ---- -== Building against unpublished JARs, that change frequently - -If a dependent Gerrit library is undergoing active development it must be -recompiled and the change must be reflected in the Buck build process. For -example testing Gerrit against changed JGit snapshot version. After building -JGit library, the artifacts are created in local Maven build directory, e. g.: - ----- - mvn package - /home//projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar - /home//projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar ----- - -If as usual, installation of the build artifacts takes place in local maven -repository, then the Buck build must fetch them from there with normal -`download_file.py` process. Disadvantage of this approach is that Buck cache -invalidation must occur to refresh the artifacts after next -change-compile-install round trip. - -To shorten that workflow and take the installation of the artifacts to the -local Maven repository and fetching it again from there out of the picture, -`local_jar()` method is used instead of `maven_jar()`: - -[source,python] ----- - local_jar( - name = 'jgit', - jar = '/home//projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar', - src = '/home//projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar', - deps = [':ewah'] - ) ----- - -This creates a symlink to the Buck targets direct against artifacts in -another project's Maven target directory: - ----- - buck-out/gen/lib/jgit/jgit.jar -> - /home//projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar ----- - -After `buck clean` and `buck build lib/jgit:jgit` the symbolic link that was -created the first time is lost due to Buck's caching mechanism. This means that -when a new version of the local artifact is deployed (by running `mvn package` -in the JGit project in the example above), Buck is not aware of it, because it -still has a stale version of it in its cache. - -To solve this problem and re-create the symbolic link, you don't need to wipe out -the entire Buck cache. Just rebuilding the target with the `--no-cache` option -does the job: - ----- - buck clean - buck build --no-cache lib/jgit:jgit ----- - == Building against artifacts from custom Maven repositories To build against custom Maven repositories, two modes of operations are diff --git a/Documentation/install-quick.txt b/Documentation/install-quick.txt index ffd68e7169..26232565b7 100644 --- a/Documentation/install-quick.txt +++ b/Documentation/install-quick.txt @@ -121,7 +121,7 @@ time setup between client and server is easier. This is done via the SSH port: ---- - user@host:~$ ssh -p 29418 user@localhost gerrit create-project --empty-commit --name demo-project + user@host:~$ ssh -p 29418 user@localhost gerrit create-project demo-project --empty-commit user@host:~$ ---- @@ -134,7 +134,7 @@ want to try out Gerrit on. First you have to create the project. This is done via the SSH port: ---- - user@host:~$ ssh -p 29418 user@localhost gerrit create-project --name demo-project + user@host:~$ ssh -p 29418 user@localhost gerrit create-project demo-project user@host:~$ ---- diff --git a/ReleaseNotes/ReleaseNotes-2.12.txt b/ReleaseNotes/ReleaseNotes-2.12.txt index 1dfba725a1..72ff9275fc 100644 --- a/ReleaseNotes/ReleaseNotes-2.12.txt +++ b/ReleaseNotes/ReleaseNotes-2.12.txt @@ -15,9 +15,10 @@ Important Notes java -jar gerrit.war init -d site_path ---- -*WARNING:* Upgrading to 2.12.x requires the server be first upgraded to 2.8 (or -2.9) and then to 2.12.x. If you are upgrading from 2.8.x or later, you may ignore -this warning and upgrade directly to 2.12.x. +*WARNING:* To use online reindexing when upgrading to 2.12.x the server must +first be upgraded to 2.8 (or 2.9) and then through 2.10 and 2.11 to 2.12.x. If +reindexing will be done offline, you may ignore this warning and upgrade directly +to 2.12.x. *WARNING:* When upgrading from version 2.8.4 or older with a site that uses Bouncy Castle Crypto, new versions of the libraries will be downloaded. The old @@ -69,7 +70,27 @@ enter the "Submitted, Merge Pending" state. GPG Keys and Signed Pushes ~~~~~~~~~~~~~~~~~~~~~~~~~~ -* TODO: Details +* Signed push can be enabled by setting +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#receive.enableSignedPush[ +`receive.enableSignedPush`] to true. ++ +When a client pushes with `git push --signed`, Gerrit ensures that the push +certificate is valid and signed with a valid public key stored in the +`refs/gpg-keys` branch of the `All-Users` repository. + +* When signed push is enabled, and +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#gerrit.editGpgKeys[ +`gerrit.editGpgKeys`] is set to true, users may upload their public GPG +key via the REST API or UI. ++ +If this setting is not enabled, GPG keys may only be added by administrators +with direct access to the `All-Users` repository. + +* Administrators may also configure +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#receive.certNonceSeed[ +`receive.certNonceSeed`] +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#receive.certNonceSlop[ +`receive.certNonceSlop`]. Secondary Index @@ -122,7 +143,18 @@ General Previously it was only possible to edit these preferences from the actual diff and edit screens. -* Add "Edits" to My dashboard menu. +* Add 'Edits' to the 'My' dashboard menu to list changes on which the user +has an unpublished edit revision. + +* Support for URL aliases. ++ +Administrators may define +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#urlAlias[ +URL aliases] to map plugin screens into the Gerrit URL namespace. ++ +Plugins may use user-specific URL aliases to replace certain screens for certain +users. + Project Screen ^^^^^^^^^^^^^^ @@ -149,6 +181,21 @@ Edit preferences are stored and loaded to/from the `All-Users` repository. Change Screen ^^^^^^^^^^^^^ +* link:http://code.google.com/p/gerrit/issues/detail?id=3318[Issue 3318]: +Highlight 'Reply' button if there are draft comments on any patch set. ++ +If any patch set of the change has a draft comment by the current user, +the 'Reply' button is highlighted. ++ +The icons depicting draft comments are removed from the revisions drop-down +list. + +* link:http://code.google.com/p/gerrit/issues/detail?id=1100[Issue 1100]: +Publish all draft comments when replying to a change. ++ +All draft comments, including those on older patch sets, are published when +replying to a change. + * Show file size increase/decrease for binary files. * Show uploader if different from change owner. @@ -170,6 +217,14 @@ Add syntax highlighting for Puppet. Add syntax highlighting for VHDL. +Group Screen +^^^^^^^^^^^^ + +* link:http://code.google.com/p/gerrit/issues/detail?id=1479[Issue 1479]: +The group screen now includes an 'Audit Log' panel showing member additions, +removals, and the user who made the change. + + API ~~~ @@ -193,12 +248,76 @@ REST API New REST API endpoints and new options on existing endpoints. -Tags -^^^^ -* Support filtering by substring and regex in the list tags endpoint. +Accounts +^^^^^^^^ -* Support pagination with `--start` and `--end` in the list tags endpoint. +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-accounts.html#set-username[ +Set Username]: Set the username of an account. + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-accounts.html#get-detail[ +Get Account Details]: Get the details of an account. ++ +In addition to the +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-accounts.html#account-info[ +AccountInfo] fields returned by the existing + link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-accounts.html#get-account[ +Get Account] endpoint, the new REST endpoint returns the registration date of +the account and the timestamp of when contact information was filed for this +account. + + +Changes +^^^^^^^ + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-changes.html#set-review[ +Set Review]: Add an option to omit duplicate comments. + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-changes.html#get-safe-content[ +Download Content]: Downloads the content of a file from a certain revision, in a +safe format that poses no risk for inadvertent execution of untrusted code. + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-changes.html#submitted-together[ +Get Submitted Together]: Get the list of all changes that will be submitted at +the same time as the change. + +* link:http://code.google.com/p/gerrit/issues/detail?id=1100[Issue 1100]: +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-changes.html#set-review[ +Set Review]: Add an option to publish draft comments on all revisions. + +Config +^^^^^^ + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-config.html#get-info[ +Get Server Info]: Returns information about the Gerrit server configuration. + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-config.html#confirm-email[ +Confirm Email]: Confirm that the user owns an email address. + + +Groups +^^^^^^ + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-groups.html#list-group[ +List Groups]: Add option to suggest groups. ++ +This allows group auto-completion to be used in a plugin's UI. + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-groups.html#get-audit-log[ +Get Audit Log]: Gets the audit log of a Gerrit internal group, showing member +additions, removals, and the user who made the change. + + +Projects +^^^^^^^^ + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-projects.html#run-gc[ +Run GC]: Add `aggressive` option to specify whether or not to run an aggressive +garbage collection. + +* link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/rest-api-projects.html#list-tags[ +List Tags]: Support filtering by substring and regex, and pagination with +`--start` and `--end`. SSH @@ -212,10 +331,51 @@ link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/conf * Add support for hmac-sha2-256 and hmac-sha2-512 as MACs. +Plugins +~~~~~~~ + +General +^^^^^^^ + +* Gerrit client can now pass JavaScriptObjects to extension panels. + +* New UI extension point for header bar in change screen. + +* New UI extension point to password screen. + +* New UI extension points to project info screen. + +* New UI extension point for pop down buttons on change screen. + +* New UI extension point for buttons in header bar on change screen. + +* New UI extension point at bottom of the user preferences screen. + +* New UI extension point for the 'Included In' drop-down panel. ++ +By implementing the +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/dev-plugins.html#included-in[ +Included In interface], plugins may add entries to the 'Included In' dropdown +menu on the change screen. + +* Plugins can extend Gerrit screens with GWT controls. + +* Plugins can add custom settings screens. + +* Referencing groups in `project.config`. ++ +Plugins can refer to groups so that when they are renamed, the project +config will also be updated in this section. + Other ~~~~~ +* link:http://code.google.com/p/gerrit/issues/detail?id=3401[Issue 3401]: +Add option to +link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/config-gerrit.html#sendemail.allowRegisterNewEmail[ +disable registration of new email addresses]. + * link:http://code.google.com/p/gerrit/issues/detail?id=2061[Issue 2061] Add Support for `git-upload-archive`. + @@ -233,7 +393,8 @@ changes and automatically abandon them. link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/database-setup.html#createdb_db2[ DB2 database]. -* Add support for the +* link:http://code.google.com/p/gerrit/issues/detail?id=3441[Issue 3441]: +Add support for the link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/database-setup.html#createdb_derby[ Apache Derby database]. @@ -247,15 +408,33 @@ working. Setting `download.checkForHiddenChangeRefs` in the `gerrit.config` to true allows the download commands plugin to check for hidden change refs. +* Add a new 'Maintain Server' global capability. ++ +Members of a group with the 'Maintain Server' capability may view caches, tasks, +and queues, and invoke the index REST API on changes. + + Bug Fixes --------- +* link:http://code.google.com/p/gerrit/issues/detail?id=3499[Issue 3499]: +Fix syntax highlighting of raw string literals in go. + +* link:http://code.google.com/p/gerrit/issues/detail?id=3643[Issue 3643]: +Fix syntax highlighting of ES6 string templating using backticks. + * link:http://code.google.com/p/gerrit/issues/detail?id=3653[Issue 3653]: Correct timezone in sshd log after DST change. + When encountering a DST switch, the timezone wasn't updated until the server was reloaded. +* link:http://code.google.com/p/gerrit/issues/detail?id=3306[Issue 3306]: +Allow admins to read, push and create on `refs/users/default`. + +* link:http://code.google.com/p/gerrit/issues/detail?id=3212[Issue 3212]: +Fix failure to run `init` when `--site-path` option is not explicitly given. + * Make email validation case insensitive. + While link:https://tools.ietf.org/html/rfc5321#section-2.3.11[ @@ -273,6 +452,16 @@ intended to be pushed to Gerrit, and don't need a `Change-Id` line. This also prevents changes from being accidentally uploaded, at least for projects that have the 'Require Change-Id' configuration enabled. +* link:http://code.google.com/p/gerrit/issues/detail?id=3444[Issue 3444]: +download-commands plugin: Fix clone with commit-msg hook when project name +contains '/'. + +* Include full ref names in `ref-updated` events. ++ +The link:https://gerrit-documentation.storage.googleapis.com/Documentation/2.12/json.html#refUpdate[ +refUpdate attribute] in `ref-updated` events did not include the full name +of the ref, i.e. `master` instead of `refs/heads/master`. + Upgrades -------- diff --git a/gerrit-gwtui/src/main/java/net/codemirror/lib/style.css b/gerrit-gwtui/src/main/java/net/codemirror/lib/style.css index 7d7ce6e201..4b97da1640 100644 --- a/gerrit-gwtui/src/main/java/net/codemirror/lib/style.css +++ b/gerrit-gwtui/src/main/java/net/codemirror/lib/style.css @@ -73,11 +73,11 @@ } .cm-searching { - background-color: #ffa; + background-color: #ffa !important; } .cm-trailingspace { - background-color: red; + background-color: red !important; } /* Line length margin displayed at NN columns to provide diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java index d5259bdec9..4e635b2e40 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/plugins/HttpPluginServlet.java @@ -641,11 +641,9 @@ class HttpPluginServlet extends HttpServlet private static byte[] readWholeEntry(PluginContentScanner scanner, PluginEntry entry) throws IOException { - byte[] data = new byte[entry.getSize().get().intValue()]; try (InputStream in = scanner.getInputStream(entry)) { - IO.readFully(in, data, 0, data.length); + return IO.readWholeStream(in, entry.getSize().get().intValue()).array(); } - return data; } private static class PluginHolder { diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitAdminUser.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitAdminUser.java index a09dcd577c..40a07b49fd 100644 --- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitAdminUser.java +++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitAdminUser.java @@ -25,6 +25,7 @@ import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountExternalId; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroupMember; +import com.google.gerrit.reviewdb.client.AccountGroupName; import com.google.gerrit.reviewdb.client.AccountSshKey; import com.google.gerrit.reviewdb.client.AuthType; import com.google.gerrit.reviewdb.server.ReviewDb; @@ -101,9 +102,11 @@ public class InitAdminUser implements InitStep { a.setPreferredEmail(email); db.accounts().insert(Collections.singleton(a)); + AccountGroupName adminGroup = db.accountGroupNames().get( + new AccountGroup.NameKey("Administrators")); AccountGroupMember m = new AccountGroupMember(new AccountGroupMember.Key(id, - new AccountGroup.Id(1))); + adminGroup.getId())); db.accountGroupMembers().insert(Collections.singleton(m)); if (sshKey != null) { diff --git a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitPlugins.java b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitPlugins.java index bb4c3144a0..6a3d7cbc21 100644 --- a/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitPlugins.java +++ b/gerrit-pgm/src/main/java/com/google/gerrit/pgm/init/InitPlugins.java @@ -112,17 +112,18 @@ public class InitPlugins implements InitStep { String pluginName = plugin.name; try { final Path tmpPlugin = plugin.pluginPath; + Path p = site.plugins_dir.resolve(plugin.name + ".jar"); + boolean upgrade = Files.exists(p); - if (!(initFlags.installPlugins.contains(pluginName) || ui.yesno(false, + if (!(initFlags.installPlugins.contains(pluginName) || ui.yesno(upgrade, "Install plugin %s version %s", pluginName, plugin.version))) { Files.deleteIfExists(tmpPlugin); continue; } - final Path p = site.plugins_dir.resolve(plugin.name + ".jar"); - if (Files.exists(p)) { + if (upgrade) { final String installedPluginVersion = getVersion(p); - if (!ui.yesno(false, + if (!ui.yesno(upgrade, "version %s is already installed, overwrite it", installedPluginVersion)) { Files.deleteIfExists(tmpPlugin); diff --git a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/CurrentSchemaVersion.java b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/CurrentSchemaVersion.java index 183bb1ef42..cba5d41968 100644 --- a/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/CurrentSchemaVersion.java +++ b/gerrit-reviewdb/src/main/java/com/google/gerrit/reviewdb/client/CurrentSchemaVersion.java @@ -26,7 +26,7 @@ public final class CurrentSchemaVersion { private static final String VALUE = "X"; @Column(id = 1, length = 1) - protected String one = VALUE; + public String one = VALUE; public Key() { } @@ -50,12 +50,12 @@ public final class CurrentSchemaVersion { } @Column(id = 1) - protected Key singleton; + public Key singleton; /** Current version number of the schema. */ @Column(id = 2) public transient int versionNbr; - protected CurrentSchemaVersion() { + public CurrentSchemaVersion() { } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/DefaultRealm.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/DefaultRealm.java index 7669cf96e8..5978703b42 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/DefaultRealm.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/DefaultRealm.java @@ -19,7 +19,6 @@ import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AuthType; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.config.AuthConfig; -import com.google.gerrit.server.mail.EmailSettings; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -28,17 +27,14 @@ import java.util.Set; @Singleton public class DefaultRealm extends AbstractRealm { private final EmailExpander emailExpander; - private final EmailSettings emailSettings; private final AccountByEmailCache byEmail; private final AuthConfig authConfig; @Inject DefaultRealm(EmailExpander emailExpander, - EmailSettings emailSettings, AccountByEmailCache byEmail, AuthConfig authConfig) { this.emailExpander = emailExpander; - this.emailSettings = emailSettings; this.byEmail = byEmail; this.authConfig = authConfig; } @@ -52,7 +48,7 @@ public class DefaultRealm extends AbstractRealm { case FULL_NAME: return Strings.emptyToNull(authConfig.getHttpDisplaynameHeader()) == null; case REGISTER_NEW_EMAIL: - return emailSettings.allowRegisterNewEmail + return authConfig.isAllowRegisterNewEmail() && Strings.emptyToNull(authConfig.getHttpEmailHeader()) == null; default: return true; @@ -60,7 +56,7 @@ public class DefaultRealm extends AbstractRealm { } else { switch (field) { case REGISTER_NEW_EMAIL: - return emailSettings.allowRegisterNewEmail; + return authConfig.isAllowRegisterNewEmail(); default: return true; } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/auth/ldap/LdapRealm.java b/gerrit-server/src/main/java/com/google/gerrit/server/auth/ldap/LdapRealm.java index 9d7f7b7b58..cd1c4d3a50 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/auth/ldap/LdapRealm.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/auth/ldap/LdapRealm.java @@ -33,7 +33,6 @@ import com.google.gerrit.server.account.EmailExpander; import com.google.gerrit.server.auth.AuthenticationUnavailableException; import com.google.gerrit.server.config.AuthConfig; import com.google.gerrit.server.config.GerritServerConfig; -import com.google.gerrit.server.mail.EmailSettings; import com.google.gwtorm.server.SchemaFactory; import com.google.inject.Inject; import com.google.inject.Singleton; @@ -79,7 +78,6 @@ public class LdapRealm extends AbstractRealm { Helper helper, AuthConfig authConfig, EmailExpander emailExpander, - EmailSettings emailSettings, @Named(LdapModule.GROUP_CACHE) final LoadingCache> membershipCache, @Named(LdapModule.USERNAME_CACHE) final LoadingCache> usernameCache, @GerritServerConfig final Config config) { @@ -98,7 +96,7 @@ public class LdapRealm extends AbstractRealm { if (optdef(config, "accountSshUserName", "DEFAULT") != null) { readOnlyAccountFields.add(Account.FieldName.USER_NAME); } - if (!emailSettings.allowRegisterNewEmail) { + if (!authConfig.isAllowRegisterNewEmail()) { readOnlyAccountFields.add(Account.FieldName.REGISTER_NEW_EMAIL); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/AuthConfig.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/AuthConfig.java index 6e6ed97ba5..c3bd519630 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/AuthConfig.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/AuthConfig.java @@ -60,6 +60,7 @@ public class AuthConfig { private final String cookiePath; private final boolean cookieSecure; private final SignedToken emailReg; + private final boolean allowRegisterNewEmail; @Inject AuthConfig(@GerritServerConfig final Config cfg) @@ -90,7 +91,7 @@ public class AuthConfig { useContributorAgreements = cfg.getBoolean("auth", "contributoragreements", false); userNameToLowerCase = cfg.getBoolean("auth", "userNameToLowerCase", false); - + allowRegisterNewEmail = cfg.getBoolean("auth", "allowRegisterNewEmail", true); String key = cfg.getString("auth", null, "registerEmailPrivateKey"); if (key != null && !key.isEmpty()) { @@ -297,4 +298,8 @@ public class AuthConfig { return authType == AuthType.LDAP || authType == AuthType.LDAP_BIND; } + + public boolean isAllowRegisterNewEmail() { + return allowRegisterNewEmail; + } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/config/SetPreferences.java b/gerrit-server/src/main/java/com/google/gerrit/server/config/SetPreferences.java index d97499cee5..519a4a4cbb 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/config/SetPreferences.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/config/SetPreferences.java @@ -23,6 +23,7 @@ import com.google.gerrit.server.account.SetPreferences.Input; import com.google.gerrit.server.account.VersionedAccountPreferences; import com.google.gerrit.server.git.MetaDataUpdate; import com.google.inject.Inject; +import com.google.inject.Provider; import com.google.inject.Singleton; import org.eclipse.jgit.errors.ConfigInvalidException; @@ -32,11 +33,11 @@ import java.io.IOException; @RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER) @Singleton public class SetPreferences implements RestModifyView { - private final MetaDataUpdate.User metaDataUpdateFactory; + private final Provider metaDataUpdateFactory; private final AllUsersName allUsersName; @Inject - SetPreferences(MetaDataUpdate.User metaDataUpdateFactory, + SetPreferences(Provider metaDataUpdateFactory, AllUsersName allUsersName) { this.metaDataUpdateFactory = metaDataUpdateFactory; this.allUsersName = allUsersName; @@ -58,7 +59,7 @@ public class SetPreferences implements RestModifyView { } VersionedAccountPreferences p; - MetaDataUpdate md = metaDataUpdateFactory.create(allUsersName); + MetaDataUpdate md = metaDataUpdateFactory.get().create(allUsersName); try { p = VersionedAccountPreferences.forDefault(); p.load(md); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java index fdededdb04..d623b31129 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java @@ -56,8 +56,9 @@ public class ListMembers implements RestReadView { this.accountLoader = accountLoaderFactory.create(true); } - public void setRecursive(boolean recursive) { + public ListMembers setRecursive(boolean recursive) { this.recursive = recursive; + return this; } @Override diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/EmailSettings.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/EmailSettings.java index 31135d0a2c..3c14f2f919 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/EmailSettings.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/EmailSettings.java @@ -22,13 +22,11 @@ import org.eclipse.jgit.lib.Config; @Singleton public class EmailSettings { - public final boolean allowRegisterNewEmail; public final boolean includeDiff; public final int maximumDiffSize; @Inject EmailSettings(@GerritServerConfig Config cfg) { - allowRegisterNewEmail = cfg.getBoolean("sendemail", "allowRegisterNewEmail", true); includeDiff = cfg.getBoolean("sendemail", "includeDiff", false); maximumDiffSize = cfg.getInt("sendemail", "maximumDiffSize", 256 << 10); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java index 2d141b62c2..440731efcc 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/ChangeQueryBuilder.java @@ -17,10 +17,14 @@ package com.google.gerrit.server.query.change; import static com.google.gerrit.server.query.change.ChangeData.asChanges; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; import com.google.common.base.Optional; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.gerrit.common.data.GroupReference; import com.google.gerrit.common.errors.NotSignedInException; +import com.google.gerrit.extensions.common.AccountInfo; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; @@ -45,9 +49,11 @@ import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.TrackingFooters; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.git.strategy.SubmitStrategyFactory; +import com.google.gerrit.server.group.ListMembers; import com.google.gerrit.server.index.ChangeIndex; import com.google.gerrit.server.index.FieldDef; import com.google.gerrit.server.index.IndexCollection; +import com.google.gerrit.server.index.IndexConfig; import com.google.gerrit.server.index.IndexRewriter; import com.google.gerrit.server.index.Schema; import com.google.gerrit.server.patch.PatchListCache; @@ -168,8 +174,10 @@ public class ChangeQueryBuilder extends QueryBuilder { final SubmitStrategyFactory submitStrategyFactory; final ConflictsCache conflictsCache; final TrackingFooters trackingFooters; - final boolean allowsDrafts; final ChangeIndex index; + final IndexConfig indexConfig; + final Provider listMembers; + final boolean allowsDrafts; private final Provider self; @@ -198,6 +206,8 @@ public class ChangeQueryBuilder extends QueryBuilder { SubmitStrategyFactory submitStrategyFactory, ConflictsCache conflictsCache, TrackingFooters trackingFooters, + IndexConfig indexConfig, + Provider listMembers, @GerritServerConfig Config cfg) { this(db, queryProvider, rewriter, opFactories, userFactory, self, capabilityControlFactory, changeControlGenericFactory, @@ -205,8 +215,9 @@ public class ChangeQueryBuilder extends QueryBuilder { allProjectsName, allUsersName, patchListCache, repoManager, projectCache, listChildProjects, submitStrategyFactory, conflictsCache, trackingFooters, - cfg == null ? true : cfg.getBoolean("change", "allowDrafts", true), - indexes != null ? indexes.getSearchIndex() : null); + indexes != null ? indexes.getSearchIndex() : null, + indexConfig, listMembers, + cfg == null ? true : cfg.getBoolean("change", "allowDrafts", true)); } private Arguments( @@ -232,8 +243,10 @@ public class ChangeQueryBuilder extends QueryBuilder { SubmitStrategyFactory submitStrategyFactory, ConflictsCache conflictsCache, TrackingFooters trackingFooters, - boolean allowsDrafts, - ChangeIndex index) { + ChangeIndex index, + IndexConfig indexConfig, + Provider listMembers, + boolean allowsDrafts) { this.db = db; this.queryProvider = queryProvider; this.rewriter = rewriter; @@ -256,8 +269,10 @@ public class ChangeQueryBuilder extends QueryBuilder { this.submitStrategyFactory = submitStrategyFactory; this.conflictsCache = conflictsCache; this.trackingFooters = trackingFooters; - this.allowsDrafts = allowsDrafts; this.index = index; + this.indexConfig = indexConfig; + this.listMembers = listMembers; + this.allowsDrafts = allowsDrafts; } Arguments asUser(CurrentUser otherUser) { @@ -267,7 +282,8 @@ public class ChangeQueryBuilder extends QueryBuilder { changeDataFactory, fillArgs, plcUtil, accountResolver, groupBackend, allProjectsName, allUsersName, patchListCache, repoManager, projectCache, listChildProjects, submitStrategyFactory, - conflictsCache, trackingFooters, allowsDrafts, index); + conflictsCache, trackingFooters, index, indexConfig, listMembers, + allowsDrafts); } Arguments asUser(Account.Id otherId) { @@ -596,6 +612,26 @@ public class ChangeQueryBuilder extends QueryBuilder { } } + // expand a group predicate into multiple user predicates + if (group != null) { + Set allMembers = + new HashSet<>(Lists.transform( + args.listMembers.get().setRecursive(true).apply(group), + new Function() { + @Override + public Account.Id apply(AccountInfo accountInfo) { + return new Account.Id(accountInfo._accountId); + } + })); + int maxTerms = args.indexConfig.maxLimit(); + if (allMembers.size() > maxTerms) { + // limit the number of query terms otherwise Gerrit will barf + accounts = ImmutableSet.copyOf(Iterables.limit(allMembers, maxTerms)); + } else { + accounts = allMembers; + } + } + return new LabelPredicate(args.projectCache, args.changeControlGenericFactory, args.userFactory, args.db, name, accounts, group); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/InternalChangeQuery.java b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/InternalChangeQuery.java index 2dde97274f..ff6f2bcecd 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/query/change/InternalChangeQuery.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/query/change/InternalChangeQuery.java @@ -245,7 +245,7 @@ public class InternalChangeQuery { return query(and(project(project), or(groupPredicates))); } - private List query(Predicate p) throws OrmException { + public List query(Predicate p) throws OrmException { try { return qp.queryChanges(p).changes(); } catch (QueryParseException e) { diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/index/FakeQueryBuilder.java b/gerrit-server/src/test/java/com/google/gerrit/server/index/FakeQueryBuilder.java index 99d68e83a3..dd03bb043a 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/index/FakeQueryBuilder.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/index/FakeQueryBuilder.java @@ -27,7 +27,7 @@ public class FakeQueryBuilder extends ChangeQueryBuilder { FakeQueryBuilder.class), new ChangeQueryBuilder.Arguments(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, indexes, null, null, null, null)); + null, null, indexes, null, null, null, null, null, null)); } @Operator diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java index 49e1796c80..fcaa738a95 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java @@ -37,6 +37,7 @@ import com.google.gerrit.extensions.api.GerritApi; import com.google.gerrit.extensions.api.changes.Changes.QueryRequest; import com.google.gerrit.extensions.api.changes.HashtagsInput; import com.google.gerrit.extensions.api.changes.ReviewInput; +import com.google.gerrit.extensions.api.groups.GroupInput; import com.google.gerrit.extensions.common.ChangeInfo; import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.lifecycle.LifecycleManager; @@ -51,11 +52,13 @@ import com.google.gerrit.server.CurrentUser; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.account.AccountManager; import com.google.gerrit.server.account.AuthRequest; +import com.google.gerrit.server.account.GroupCache; import com.google.gerrit.server.change.ChangeInserter; import com.google.gerrit.server.change.ChangeTriplet; import com.google.gerrit.server.change.PatchSetInserter; import com.google.gerrit.server.git.BatchUpdate; import com.google.gerrit.server.git.validators.CommitValidators; +import com.google.gerrit.server.group.AddMembers; import com.google.gerrit.server.index.ChangeField; import com.google.gerrit.server.index.IndexCollection; import com.google.gerrit.server.notedb.NotesMigration; @@ -119,6 +122,8 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests { @Inject protected QueryProcessor queryProcessor; @Inject protected SchemaCreator schemaCreator; @Inject protected ThreadLocalRequestContext requestContext; + @Inject protected GroupCache groupCache; + @Inject protected AddMembers addMembers; protected LifecycleManager lifecycle; protected ReviewDb db; @@ -576,6 +581,49 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests { assertQuery("label:Code-Review=+1,group=Administrators", change); } + private String createGroup(String name, String owner) throws Exception { + GroupInput in = new GroupInput(); + in.name = name; + in.ownerId = owner; + gApi.groups().create(in); + return name; + } + + private Account.Id createAccount(String name) throws Exception { + return accountManager.authenticate( + AuthRequest.forUser(name)).getAccountId(); + } + + @Test + public void byLabelGroup() throws Exception { + Account.Id user1 = createAccount("user1"); + createAccount("user2"); + TestRepository repo = createProject("repo"); + + // create group and add users + String g1 = createGroup("group1", "Administrators"); + String g2 = createGroup("group2", "Administrators"); + gApi.groups().id(g1).addMembers("user1"); + gApi.groups().id(g2).addMembers("user2"); + + // create a change + ChangeInserter ins = newChange(repo, null, null, user1.get(), null); + Change change1 = insert(ins); + + // post a review with user1 + requestContext.setContext(newRequestContext(user1)); + gApi.changes().id(change1.getId().get()).current() + .review(new ReviewInput().label("Code-Review", 1)); + + // verify that query with user1 will return results. + requestContext.setContext(newRequestContext(userId)); + assertQuery("label:Code-Review=+1,group1", change1); + assertQuery("label:Code-Review=+1,group=group1", change1); + assertQuery("label:Code-Review=+1,user=user1", change1); + assertQuery("label:Code-Review=+1,user=user2"); + assertQuery("label:Code-Review=+1,group=group2"); + } + @Test public void limit() throws Exception { TestRepository repo = createProject("repo"); diff --git a/lib/local.defs b/lib/local.defs deleted file mode 100644 index 6eec581a0d..0000000000 --- a/lib/local.defs +++ /dev/null @@ -1,33 +0,0 @@ -def local_jar( - name, - jar, - src = None, - deps = [], - visibility = ['PUBLIC']): - binjar = name + '.jar' - srcjar = name + '-src.jar' - genrule( - name = '%s__local_bin' % name, - cmd = 'ln -s %s $OUT' % jar, - out = binjar) - if src: - genrule( - name = '%s__local_src' % name, - cmd = 'ln -s %s $OUT' % src, - out = srcjar) - prebuilt_jar( - name = '%s_src' % name, - binary_jar = ':%s__local_src' % name, - visibility = visibility, - ) - else: - srcjar = None - - prebuilt_jar( - name = name, - deps = deps, - binary_jar = ':%s__local_bin' % name, - source_jar = ':%s__local_src' % name if srcjar else None, - visibility = visibility, - ) - diff --git a/lib/maven.defs b/lib/maven.defs index a16fda1281..5c29beda36 100644 --- a/lib/maven.defs +++ b/lib/maven.defs @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -include_defs('//lib/local.defs') - GERRIT = 'GERRIT:' GERRIT_API = 'GERRIT_API:' MAVEN_CENTRAL = 'MAVEN_CENTRAL:'