Merge changes I615b109f,I261f140c,Ia6ffd80e
* changes: Superproject Subscriptions: test more corner cases AbstractSubmoduleSubscription: test for pushes to be valid Fix "submoduleOp: Move checking for existence to SubmoduleOp"
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.git;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.common.data.Permission;
|
import com.google.gerrit.common.data.Permission;
|
||||||
@@ -31,7 +32,10 @@ import org.eclipse.jgit.revwalk.RevCommit;
|
|||||||
import org.eclipse.jgit.revwalk.RevObject;
|
import org.eclipse.jgit.revwalk.RevObject;
|
||||||
import org.eclipse.jgit.revwalk.RevTree;
|
import org.eclipse.jgit.revwalk.RevTree;
|
||||||
import org.eclipse.jgit.revwalk.RevWalk;
|
import org.eclipse.jgit.revwalk.RevWalk;
|
||||||
|
import org.eclipse.jgit.transport.PushResult;
|
||||||
import org.eclipse.jgit.transport.RefSpec;
|
import org.eclipse.jgit.transport.RefSpec;
|
||||||
|
import org.eclipse.jgit.transport.RemoteRefUpdate;
|
||||||
|
import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@@ -57,12 +61,21 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
|
|||||||
.message(message)
|
.message(message)
|
||||||
.add("a.txt", "a contents: " + contentCounter.incrementAndGet())
|
.add("a.txt", "a contents: " + contentCounter.incrementAndGet())
|
||||||
.create();
|
.create();
|
||||||
String refspec = "HEAD:" + ref;
|
|
||||||
|
String pushedRef = ref;
|
||||||
if (!topic.isEmpty()) {
|
if (!topic.isEmpty()) {
|
||||||
refspec += "/" + topic;
|
pushedRef += "/" + topic;
|
||||||
}
|
}
|
||||||
repo.git().push().setRemote("origin").setRefSpecs(
|
String refspec = "HEAD:" + pushedRef;
|
||||||
new RefSpec(refspec)).call();
|
|
||||||
|
Iterable<PushResult> res = repo.git().push()
|
||||||
|
.setRemote("origin").setRefSpecs(new RefSpec(refspec)).call();
|
||||||
|
|
||||||
|
RemoteRefUpdate u = Iterables.getOnlyElement(res).getRemoteUpdate(pushedRef);
|
||||||
|
assertThat(u).isNotNull();
|
||||||
|
assertThat(u.getStatus()).isEqualTo(Status.OK);
|
||||||
|
assertThat(u.getNewObjectId()).isEqualTo(ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -107,6 +107,33 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
"subscribed-to-project", subHEAD);
|
"subscribed-to-project", subHEAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriptionWildcardACLForMissingProject() throws Exception {
|
||||||
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
|
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
||||||
|
"not-existing-super-project", "refs/heads/*");
|
||||||
|
pushChangeTo(subRepo, "master");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriptionWildcardACLForMissingBranch() throws Exception {
|
||||||
|
createProjectWithPush("super-project");
|
||||||
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
|
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
||||||
|
"super-project", "refs/heads/*");
|
||||||
|
pushChangeTo(subRepo, "foo");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriptionWildcardACLForMissingGitmodules() throws Exception {
|
||||||
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
|
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
||||||
|
"super-project", "refs/heads/*");
|
||||||
|
pushChangeTo(superRepo, "master");
|
||||||
|
pushChangeTo(subRepo, "master");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSubscriptionWildcardACLOneOnOneMapping() throws Exception {
|
public void testSubscriptionWildcardACLOneOnOneMapping() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
|
@@ -152,10 +152,10 @@ public class SubmoduleOp {
|
|||||||
Project.NameKey p = targetBranch.getParentKey();
|
Project.NameKey p = targetBranch.getParentKey();
|
||||||
try {
|
try {
|
||||||
orm.openRepo(p, false);
|
orm.openRepo(p, false);
|
||||||
OpenRepo or = orm.getRepo(project);
|
OpenRepo or = orm.getRepo(p);
|
||||||
ObjectId id = or.repo.resolve(branch.get());
|
ObjectId id = or.repo.resolve(targetBranch.get());
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
logDebug("The branch " + branch + " doesn't exist.");
|
logDebug("The branch " + targetBranch + " doesn't exist.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} catch (NoSuchProjectException e) {
|
} catch (NoSuchProjectException e) {
|
||||||
|
Reference in New Issue
Block a user