Submodule subscriptions: accept allowed but unsubscribed subscriptions
The current code produces a NPE when there are projects allowed to be subscribed, but are not subscribed. This happens as the load() function returns early without initializing `subscriptions`. To fix that issue, we'll move the code from `load()` into the constructor and make sure that `subscriptions` is always assigned a value. Also add a regression test. Change-Id: Ia66930a1f7d40f7feef990e1b82d6ceb886d55f9 Signed-off-by: Stefan Beller <sbeller@google.com>
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.git;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.acceptance.GerritConfig;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -27,7 +28,9 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevTree;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.transport.PushResult;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.transport.RemoteRefUpdate;
|
||||
import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
@@ -355,6 +358,31 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
"subscribed-to-project", subHEAD);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllowedButNotSubscribed() throws Exception {
|
||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||
"super-project", "refs/heads/master");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
subRepo.branch("HEAD").commit().insertChangeId()
|
||||
.message("some change")
|
||||
.add("b.txt", "b contents for testing")
|
||||
.create();
|
||||
String refspec = "HEAD:refs/heads/master";
|
||||
PushResult r = Iterables.getOnlyElement(subRepo.git().push()
|
||||
.setRemote("origin")
|
||||
.setRefSpecs(new RefSpec(refspec))
|
||||
.call());
|
||||
assertThat(r.getMessages()).doesNotContain("error");
|
||||
assertThat(r.getRemoteUpdate("refs/heads/master").getStatus())
|
||||
.isEqualTo(RemoteRefUpdate.Status.OK);
|
||||
|
||||
assertThat(hasSubmodule(superRepo, "master",
|
||||
"subscribed-to-project")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubscriptionDeepRelative() throws Exception {
|
||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||
|
||||
Reference in New Issue
Block a user