Merge branch 'stable-2.15'

* stable-2.15:
  ChangeIT: Temporarily disable tests related to group matching
  Align SSH create-project with REST API
  SubmoduleOp: Fix formatting of submodule update commit message
  Fix Postgresql JDBC driver leaking memory
  Document that the build works with Python 2 or 3
  merge_jars.py: Fix for python 3 compatibility
  project.py: decode byte output from check_result
  license and doc: Add support for python3
  Bazel: Make build tool chain python 3 compatible
  ExternalIds NoteDb migration: Avoid intermediate migration state
  Make PrivateStateChanged and WorkInProgressStateChanged singletons
  BatchProgramModule: Bind GitReferenceUpdated.DISABLED
  BatchProgramModule: Don't bind event classes to null
  Document that Python 2 is required by the build
  Make event firing classes singleton
  Fix ConcurrentModificationException when posting reviews
  Revert partially "Trim multi-line arguments for task name and ssh_log"
  BaseCommand: Fix formatting of task description with arguments
  Add analytics to the list of plugins
  config-plugins: Consistently use "/+doc/" for documentation links
  config-plugins: Fix link to ref-protection plugin documentation
  config-plugins: Add readonly plugin to plugin list
  Add documentation for SshCreateCommandInterceptor
  Allow plugins to intercept ssh command creation
  GWT/Poly: Default to "Create initial commit" during project creation
  Revert "Reduce chance of deadlock in account cache"
  commit-msg: Adapt to awk behavior change on Cygwin/MSYS
  Expand docs on how to include external dependencies in core plugins
  Document how to bundle custom plugins in release.war
  Group members can't be added as reviewers if a matched username exists
  Set version to 2.13.11
  StreamEventsApiListener: Prevent NPE when account is null
  Set version to 2.11.11
  Replace links to code.google.com/p/gerrit
  Update issue tracker URL in documentation
  Update issue tracker URL in POM files
  Bump jsch to 0.54
  Update jsch to 0.1.53
  Bump Jsch to 1.52

Change-Id: Icec3dcfe53146da7d66d4d690afdd9e77ee10380
This commit is contained in:
David Pursehouse
2018-03-12 08:52:08 +09:00
43 changed files with 378 additions and 34 deletions

View File

@@ -85,6 +85,7 @@ import com.google.gerrit.extensions.api.changes.ReviewInput.DraftHandling;
import com.google.gerrit.extensions.api.changes.ReviewResult;
import com.google.gerrit.extensions.api.changes.RevisionApi;
import com.google.gerrit.extensions.api.changes.StarsInput;
import com.google.gerrit.extensions.api.groups.GroupApi;
import com.google.gerrit.extensions.api.projects.BranchInput;
import com.google.gerrit.extensions.api.projects.ConfigInput;
import com.google.gerrit.extensions.client.ChangeKind;
@@ -167,6 +168,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.transport.PushResult;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@NoHttpd
@@ -1504,6 +1506,100 @@ public class ChangeIT extends AbstractDaemonTest {
assertThat(sender.getMessages()).hasSize(1);
}
@Ignore
@Test
public void addReviewerThatIsNotPerfectMatch() throws Exception {
TestTimeUtil.resetWithClockStep(1, SECONDS);
PushOneCommit.Result r = createChange();
ChangeResource rsrc = parseResource(r);
String oldETag = rsrc.getETag();
Timestamp oldTs = rsrc.getChange().getLastUpdatedOn();
//create a group named "ab" with one user: testUser
TestAccount testUser = accountCreator.create("abcd", "abcd@test.com", "abcd");
String testGroup = createGroupWithRealName("ab");
GroupApi groupApi = gApi.groups().id(testGroup);
groupApi.description("test group");
groupApi.addMembers(user.fullName);
AddReviewerInput in = new AddReviewerInput();
in.reviewer = "abc";
gApi.changes().id(r.getChangeId()).addReviewer(in.reviewer);
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(testUser.emailAddress);
assertThat(m.body()).contains("Hello " + testUser.fullName + ",\n");
assertThat(m.body()).contains("I'd like you to do a code review.");
assertThat(m.body()).contains("Change subject: " + PushOneCommit.SUBJECT + "\n");
assertMailReplyTo(m, testUser.email);
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
// When NoteDb is enabled adding a reviewer records that user as reviewer
// in NoteDb. When NoteDb is disabled adding a reviewer results in a dummy 0
// approval on the change which is treated as CC when the ChangeInfo is
// created.
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(testUser.getId().get());
// Ensure ETag and lastUpdatedOn are updated.
rsrc = parseResource(r);
assertThat(rsrc.getETag()).isNotEqualTo(oldETag);
assertThat(rsrc.getChange().getLastUpdatedOn()).isNotEqualTo(oldTs);
}
@Ignore
@Test
public void addGroupAsReviewersWhenANotPerfectMatchedUserExists() throws Exception {
TestTimeUtil.resetWithClockStep(1, SECONDS);
PushOneCommit.Result r = createChange();
ChangeResource rsrc = parseResource(r);
String oldETag = rsrc.getETag();
Timestamp oldTs = rsrc.getChange().getLastUpdatedOn();
//create a group named "us" with one user: testUser
TestAccount testUser = accountCreator.create("testUser", "testUser@test.com", "testUser");
String testGroup =
createGroupWithRealName(user.fullName.substring(0, user.fullName.length() / 2));
GroupApi groupApi = gApi.groups().id(testGroup);
groupApi.description("test group");
groupApi.addMembers(testUser.fullName);
//ensure that user "user" is not in the group
groupApi.removeMembers(user.fullName);
AddReviewerInput in = new AddReviewerInput();
in.reviewer = testGroup;
gApi.changes().id(r.getChangeId()).addReviewer(in.reviewer);
List<Message> messages = sender.getMessages();
assertThat(messages).hasSize(1);
Message m = messages.get(0);
assertThat(m.rcpt()).containsExactly(testUser.emailAddress);
assertThat(m.body()).contains("Hello " + testUser.fullName + ",\n");
assertThat(m.body()).contains("I'd like you to do a code review.");
assertThat(m.body()).contains("Change subject: " + PushOneCommit.SUBJECT + "\n");
assertMailReplyTo(m, testUser.email);
ChangeInfo c = gApi.changes().id(r.getChangeId()).get();
// When NoteDb is enabled adding a reviewer records that user as reviewer
// in NoteDb. When NoteDb is disabled adding a reviewer results in a dummy 0
// approval on the change which is treated as CC when the ChangeInfo is
// created.
Collection<AccountInfo> reviewers = c.reviewers.get(REVIEWER);
assertThat(reviewers).isNotNull();
assertThat(reviewers).hasSize(1);
assertThat(reviewers.iterator().next()._accountId).isEqualTo(testUser.getId().get());
// Ensure ETag and lastUpdatedOn are updated.
rsrc = parseResource(r);
assertThat(rsrc.getETag()).isNotEqualTo(oldETag);
assertThat(rsrc.getChange().getLastUpdatedOn()).isNotEqualTo(oldTs);
}
@Test
public void addReviewerWithNoteDbWhenDummyApprovalInReviewDbExists() throws Exception {
assume().that(notesMigration.readChanges()).isTrue();

View File

@@ -313,6 +313,52 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT extends AbstractSubmoduleSu
expectToHaveSubmoduleState(superRepo, "master", "sub2", sub2, "master");
expectToHaveSubmoduleState(superRepo, "master", "sub3", sub3, "master");
String sub1HEAD =
sub1.git()
.fetch()
.setRemote("origin")
.call()
.getAdvertisedRef("refs/heads/master")
.getObjectId()
.name();
String sub2HEAD =
sub2.git()
.fetch()
.setRemote("origin")
.call()
.getAdvertisedRef("refs/heads/master")
.getObjectId()
.name();
String sub3HEAD =
sub3.git()
.fetch()
.setRemote("origin")
.call()
.getAdvertisedRef("refs/heads/master")
.getObjectId()
.name();
if (getSubmitType() == SubmitType.MERGE_IF_NECESSARY) {
expectToHaveCommitMessage(
superRepo,
"master",
"Update git submodules\n\n"
+ "* Update "
+ name("sub3")
+ " from branch 'master'\n to "
+ sub3HEAD
+ "\n\n* Update "
+ name("sub2")
+ " from branch 'master'\n to "
+ sub2HEAD
+ "\n\n* Update "
+ name("sub1")
+ " from branch 'master'\n to "
+ sub1HEAD);
}
superRepo
.git()
.fetch()