Merge branch 'stable-2.16'

* stable-2.16:
  Update git submodules
  Update git submodules
  Update cmd-stream-events doc
  PG: Set diff line lenght to 72 for commit message
  Add support for 'base' in cherry pick dialog
  Update git submodules
  Update git submodules
  CommitValidators: Inject UrlFormatter via DynamicItem
  Allow omitting action in permission removal
  Fix support for ldap groups that contains spaces
  AccountIT: Extend assertKeyEquals to check that full key is included
  Fix GPG public key export

Change-Id: Ia5396777b9922d090088fea4c010d2f1c6179534
This commit is contained in:
David Pursehouse
2019-02-22 11:34:58 +09:00
9 changed files with 58 additions and 28 deletions

View File

@@ -280,6 +280,8 @@ type:: wip-state-changed
change:: link:json.html#change[change attribute]
patchSet:: link:json.html#patchSet[patchSet attribute]
changer:: link:json.html#account[account attribute]
eventCreatedOn:: Time in seconds since the UNIX epoch when this event was
@@ -294,6 +296,8 @@ type:: private-state-changed
change:: link:json.html#change[change attribute]
patchSet:: link:json.html#patchSet[patchSet attribute]
changer:: link:json.html#account[account attribute]
eventCreatedOn:: Time in seconds since the UNIX epoch when this event was

View File

@@ -219,13 +219,14 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
Iterator<String> userIds = key.getUserIDs();
info.userIds = ImmutableList.copyOf(userIds);
try (ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
ArmoredOutputStream aout = new ArmoredOutputStream(out)) {
// This is not exactly the key stored in the store, but is equivalent. In
// particular, it will have a Bouncy Castle version string. The armored
// stream reader in PublicKeyStore doesn't give us an easy way to extract
// the original ASCII armor.
key.encode(aout);
try (ByteArrayOutputStream out = new ByteArrayOutputStream(4096)) {
try (ArmoredOutputStream aout = new ArmoredOutputStream(out)) {
// This is not exactly the key stored in the store, but is equivalent. In
// particular, it will have a Bouncy Castle version string. The armored
// stream reader in PublicKeyStore doesn't give us an easy way to extract
// the original ASCII armor.
key.encode(aout);
}
info.key = new String(out.toByteArray(), UTF_8);
}
}

View File

@@ -28,6 +28,7 @@ import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.FooterConstants;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.ConsistencyProblemInfo;
import com.google.gerrit.extensions.registration.DynamicItem;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.BooleanProjectConfig;
@@ -88,7 +89,7 @@ public class CommitValidators {
@Singleton
public static class Factory {
private final PersonIdent gerritIdent;
private final UrlFormatter urlFormatter;
private final DynamicItem<UrlFormatter> urlFormatter;
private final PluginSetContext<CommitValidationListener> pluginValidators;
private final GitRepositoryManager repoManager;
private final AllUsersName allUsers;
@@ -102,7 +103,7 @@ public class CommitValidators {
@Inject
Factory(
@GerritPersonIdent PersonIdent gerritIdent,
UrlFormatter urlFormatter,
DynamicItem<UrlFormatter> urlFormatter,
@GerritServerConfig Config cfg,
PluginSetContext<CommitValidationListener> pluginValidators,
GitRepositoryManager repoManager,
@@ -142,11 +143,16 @@ public class CommitValidators {
new UploadMergesPermissionValidator(perm),
new ProjectStateValidationListener(projectState),
new AmendedGerritMergeCommitValidationListener(perm, gerritIdent),
new AuthorUploaderValidator(user, perm, urlFormatter),
new CommitterUploaderValidator(user, perm, urlFormatter),
new AuthorUploaderValidator(user, perm, urlFormatter.get()),
new CommitterUploaderValidator(user, perm, urlFormatter.get()),
new SignedOffByValidator(user, perm, projectState),
new ChangeIdValidator(
projectState, user, urlFormatter, installCommitMsgHookCommand, sshInfo, change),
projectState,
user,
urlFormatter.get(),
installCommitMsgHookCommand,
sshInfo,
change),
new ConfigValidator(projectConfigFactory, branch, user, rw, allUsers, allProjects),
new BannedCommitsValidator(rejectCommits),
new PluginCommitValidationListener(pluginValidators),
@@ -170,10 +176,15 @@ public class CommitValidators {
new UploadMergesPermissionValidator(perm),
new ProjectStateValidationListener(projectState),
new AmendedGerritMergeCommitValidationListener(perm, gerritIdent),
new AuthorUploaderValidator(user, perm, urlFormatter),
new AuthorUploaderValidator(user, perm, urlFormatter.get()),
new SignedOffByValidator(user, perm, projectCache.checkedGet(branch.getParentKey())),
new ChangeIdValidator(
projectState, user, urlFormatter, installCommitMsgHookCommand, sshInfo, change),
projectState,
user,
urlFormatter.get(),
installCommitMsgHookCommand,
sshInfo,
change),
new ConfigValidator(projectConfigFactory, branch, user, rw, allUsers, allProjects),
new PluginCommitValidationListener(pluginValidators),
new ExternalIdUpdateListener(allUsers, externalIdsConsistencyChecker),
@@ -202,8 +213,8 @@ public class CommitValidators {
ImmutableList.of(
new UploadMergesPermissionValidator(perm),
new ProjectStateValidationListener(projectCache.checkedGet(branch.getParentKey())),
new AuthorUploaderValidator(user, perm, urlFormatter),
new CommitterUploaderValidator(user, perm, urlFormatter)));
new AuthorUploaderValidator(user, perm, urlFormatter.get()),
new CommitterUploaderValidator(user, perm, urlFormatter.get())));
}
}

View File

@@ -2850,7 +2850,9 @@ public class AccountIT extends AbstractDaemonTest {
.isEqualTo(Fingerprint.toString(expected.getPublicKey().getFingerprint()));
List<String> userIds = ImmutableList.copyOf(expected.getPublicKey().getUserIDs());
assertThat(actual.userIds).named(id).containsExactlyElementsIn(userIds);
assertThat(actual.key).named(id).startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----\n");
String key = actual.key;
assertThat(key).named(id).startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----\n");
assertThat(key).named(id).endsWith("-----END PGP PUBLIC KEY BLOCK-----\n");
assertThat(actual.status).isEqualTo(GpgKeyInfo.Status.TRUSTED);
assertThat(actual.problems).isEmpty();
}

View File

@@ -199,7 +199,7 @@
_handleSavingIncludedGroups() {
return this.$.restAPI.saveIncludedGroup(this._groupName,
this._includedGroupSearchId, err => {
this._includedGroupSearchId.replace(/\+/g, ' '), err => {
if (err.status === 404) {
this.dispatchEvent(new CustomEvent('show-alert', {
detail: {message: SAVING_ERROR_TEXT},
@@ -223,7 +223,7 @@
},
_handleDeleteIncludedGroup(e) {
const id = decodeURIComponent(e.model.get('item.id'));
const id = decodeURIComponent(e.model.get('item.id')).replace(/\+/g, ' ');
const name = e.model.get('item.name');
const item = name || id;
if (!item) { return ''; }

View File

@@ -249,7 +249,7 @@
_handleAddRuleItem(e) {
// The group id is encoded, but have to decode in order for the access
// API to work as expected.
const groupId = decodeURIComponent(e.detail.value.id);
const groupId = decodeURIComponent(e.detail.value.id).replace(/\+/g, ' ');
this.set(['permission', 'value', 'rules', groupId], {});
// Purposely don't recompute sorted array so that the newly added rule

View File

@@ -310,11 +310,11 @@ limitations under the License.
element.name = 'Priority';
element.section = 'refs/*';
element.groups = {};
element.$.groupAutocomplete.text = 'new group name';
element.$.groupAutocomplete.text = 'ldap/tests tests';
const e = {
detail: {
value: {
id: 'newUserGroupId',
id: 'ldap:CN=test+test',
},
},
};
@@ -323,11 +323,11 @@ limitations under the License.
assert.equal(Object.keys(element._groupsWithRules).length, 2);
element._handleAddRuleItem(e);
flushAsynchronousOperations();
assert.deepEqual(element.groups, {newUserGroupId: {
name: 'new group name'}});
assert.deepEqual(element.groups, {'ldap:CN=test test': {
name: 'ldap/tests tests'}});
assert.equal(element._rules.length, 3);
assert.equal(Object.keys(element._groupsWithRules).length, 3);
assert.deepEqual(element.permission.value.rules['newUserGroupId'],
assert.deepEqual(element.permission.value.rules['ldap:CN=test test'],
{action: 'ALLOW', min: -2, max: 2, added: true});
// New rule should be removed if cancel from editing.
element.editing = false;

View File

@@ -92,6 +92,16 @@
return content;
};
const COMMIT_MSG_PATH = '/COMMIT_MSG';
/**
* 72 is the inofficial length standard for git commit messages.
* Derived from the fact that git log/show appends 4 ws in the beginning of
* each line when displaying commit messages. To center the commit message
* in an 80 char terminal a 4 ws border is added to the rightmost side:
* 4 + 72 + 4
*/
const COMMIT_MSG_LINE_LENGTH = 72;
Polymer({
is: 'gr-diff',
@@ -640,17 +650,19 @@
this._blame = null;
const lineLength = this.path === COMMIT_MSG_PATH ?
COMMIT_MSG_LINE_LENGTH : prefs.line_length;
const stylesToUpdate = {};
if (prefs.line_wrapping) {
this._diffTableClass = 'full-width';
if (this.viewMode === 'SIDE_BY_SIDE') {
stylesToUpdate['--content-width'] = 'none';
stylesToUpdate['--line-limit'] = prefs.line_length + 'ch';
stylesToUpdate['--line-limit'] = lineLength + 'ch';
}
} else {
this._diffTableClass = '';
stylesToUpdate['--content-width'] = prefs.line_length + 'ch';
stylesToUpdate['--content-width'] = lineLength + 'ch';
}
if (prefs.font_size) {