AbstractSubmoduleSubscription: Also support non-subscribed submodules
Rename prepareSubscriptionConfigEntry to prepareSubmoduleConfigEntry, and make the subscribeToBranch parameter optional. When null is given, the "branch" value is not added in the config, which means that the submodule should be manually updated rather than being automatically updated by the subscription. This will make it possible to reuse these methods for tests that need to add/update submodules. Change-Id: Ib3b18e05daecff885b19810272e6fa836914a696
This commit is contained in:
committed by
Edwin Kempin
parent
9b9f6ba1d5
commit
a8f17980c7
@@ -62,14 +62,14 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
|
||||
return pushChangeTo(repo, "refs/heads/" + branch, "some change", "");
|
||||
}
|
||||
|
||||
protected void createSubscription(TestRepository<?> repo, String branch,
|
||||
protected void createSubmoduleSubscription(TestRepository<?> repo, String branch,
|
||||
String subscribeToRepo, String subscribeToBranch) throws Exception {
|
||||
Config config = new Config();
|
||||
prepareSubscriptionConfigEntry(config, subscribeToRepo, subscribeToBranch);
|
||||
pushSubscriptionConfig(repo, branch, config);
|
||||
prepareSubmoduleConfigEntry(config, subscribeToRepo, subscribeToBranch);
|
||||
pushSubmoduleConfig(repo, branch, config);
|
||||
}
|
||||
|
||||
protected void prepareSubscriptionConfigEntry(Config config,
|
||||
protected void prepareSubmoduleConfigEntry(Config config,
|
||||
String subscribeToRepo, String subscribeToBranch) {
|
||||
subscribeToRepo = name(subscribeToRepo);
|
||||
// The submodule subscription module checks for gerrit.canonicalWebUrl to
|
||||
@@ -79,10 +79,12 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
|
||||
+ subscribeToRepo;
|
||||
config.setString("submodule", subscribeToRepo, "path", subscribeToRepo);
|
||||
config.setString("submodule", subscribeToRepo, "url", url);
|
||||
config.setString("submodule", subscribeToRepo, "branch", subscribeToBranch);
|
||||
if (subscribeToBranch != null) {
|
||||
config.setString("submodule", subscribeToRepo, "branch", subscribeToBranch);
|
||||
}
|
||||
}
|
||||
|
||||
protected void pushSubscriptionConfig(TestRepository<?> repo,
|
||||
protected void pushSubmoduleConfig(TestRepository<?> repo,
|
||||
String branch, Config config) throws Exception {
|
||||
|
||||
repo.branch("HEAD").commit().insertChangeId()
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
ObjectId subHEAD = pushChangeTo(subRepo, "master");
|
||||
expectToHaveSubmoduleState(superRepo, "master",
|
||||
"subscribed-to-project", subHEAD);
|
||||
@@ -45,7 +45,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
ObjectId subHEAD = pushChangeTo(subRepo, "master");
|
||||
expectToHaveSubmoduleState(superRepo, "master",
|
||||
"subscribed-to-project", subHEAD);
|
||||
@@ -58,7 +58,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
|
||||
// The first update doesn't include any commit messages
|
||||
ObjectId subRepoId = pushChangeTo(subRepo, "master");
|
||||
@@ -82,7 +82,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
ObjectId subHEAD = pushChangeTo(subRepo, "master");
|
||||
|
||||
// The first update doesn't include the rev log
|
||||
@@ -110,7 +110,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
ObjectId subHEADbeforeUnsubscribing = pushChangeTo(subRepo, "master");
|
||||
@@ -133,7 +133,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
ObjectId subHEADbeforeUnsubscribing = pushChangeTo(subRepo, "master");
|
||||
@@ -155,7 +155,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "foo");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "foo");
|
||||
ObjectId subFoo = pushChangeTo(subRepo, "foo");
|
||||
pushChangeTo(subRepo, "master");
|
||||
|
||||
@@ -169,8 +169,8 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
|
||||
pushChangeTo(subRepo, "master");
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubscription(subRepo, "master", "super-project", "master");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubmoduleSubscription(subRepo, "master", "super-project", "master");
|
||||
|
||||
ObjectId subHEAD = pushChangeTo(subRepo, "master");
|
||||
pushChangeTo(superRepo, "master");
|
||||
|
||||
@@ -41,7 +41,7 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
||||
public void testSubscriptionUpdateOfManyChanges() throws Exception {
|
||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||
createSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||
|
||||
ObjectId subHEAD = subRepo.branch("HEAD").commit().insertChangeId()
|
||||
.message("some change")
|
||||
@@ -97,10 +97,10 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
||||
TestRepository<?> sub3 = createProjectWithPush("sub3");
|
||||
|
||||
Config config = new Config();
|
||||
prepareSubscriptionConfigEntry(config, "sub1", "master");
|
||||
prepareSubscriptionConfigEntry(config, "sub2", "master");
|
||||
prepareSubscriptionConfigEntry(config, "sub3", "master");
|
||||
pushSubscriptionConfig(superRepo, "master", config);
|
||||
prepareSubmoduleConfigEntry(config, "sub1", "master");
|
||||
prepareSubmoduleConfigEntry(config, "sub2", "master");
|
||||
prepareSubmoduleConfigEntry(config, "sub3", "master");
|
||||
pushSubmoduleConfig(superRepo, "master", config);
|
||||
|
||||
ObjectId superPreviousId = pushChangeTo(superRepo, "master");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user