submodule subscriptions: ensure nested relative projects work

We never test relative paths in submodule subscriptions, so add
a test for it.

Change-Id: Iec213b8a553aa5624e2c7c072b4bfb2f9216ed03
This commit is contained in:
Stefan Beller
2016-05-26 15:48:48 -07:00
parent 445f549f9c
commit 85b276b3be
2 changed files with 47 additions and 7 deletions

View File

@@ -71,13 +71,6 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
return pushChangeTo(repo, "refs/heads/" + branch, "some change", "");
}
protected void createSubmoduleSubscription(TestRepository<?> repo, String branch,
String subscribeToRepo, String subscribeToBranch) throws Exception {
Config config = new Config();
prepareSubmoduleConfigEntry(config, subscribeToRepo, subscribeToBranch);
pushSubmoduleConfig(repo, branch, config);
}
protected void allowSubmoduleSubscription(String submodule, String subBranch,
String superproject, String superBranch) throws Exception {
Project.NameKey sub = new Project.NameKey(name(submodule));
@@ -99,6 +92,34 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
}
}
protected void createSubmoduleSubscription(TestRepository<?> repo, String branch,
String subscribeToRepo, String subscribeToBranch) throws Exception {
Config config = new Config();
prepareSubmoduleConfigEntry(config, subscribeToRepo, subscribeToBranch);
pushSubmoduleConfig(repo, branch, config);
}
protected void createRelativeSubmoduleSubscription(TestRepository<?> repo,
String branch, String subscribeToRepoPrefix, String subscribeToRepo,
String subscribeToBranch) throws Exception {
Config config = new Config();
prepareRelativeSubmoduleConfigEntry(config, subscribeToRepoPrefix,
subscribeToRepo, subscribeToBranch);
pushSubmoduleConfig(repo, branch, config);
}
protected void prepareRelativeSubmoduleConfigEntry(Config config,
String subscribeToRepoPrefix, String subscribeToRepo,
String subscribeToBranch) {
subscribeToRepo = name(subscribeToRepo);
String url = subscribeToRepoPrefix + subscribeToRepo;
config.setString("submodule", subscribeToRepo, "path", subscribeToRepo);
config.setString("submodule", subscribeToRepo, "url", url);
if (subscribeToBranch != null) {
config.setString("submodule", subscribeToRepo, "branch", subscribeToBranch);
}
}
protected void prepareSubmoduleConfigEntry(Config config,
String subscribeToRepo, String subscribeToBranch) {
subscribeToRepo = name(subscribeToRepo);

View File

@@ -353,6 +353,25 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
"subscribed-to-project")).isFalse();
}
@Test
public void testSubscriptionDeepRelative() throws Exception {
TestRepository<?> superRepo = createProjectWithPush("super-project");
TestRepository<?> subRepo = createProjectWithPush(
"nested/subscribed-to-project");
// master is allowed to be subscribed to any superprojects branch:
allowSubmoduleSubscription("nested/subscribed-to-project",
"refs/heads/master", "super-project", null);
pushChangeTo(subRepo, "master");
createRelativeSubmoduleSubscription(superRepo, "master",
"../", "nested/subscribed-to-project", "master");
ObjectId subHEAD = pushChangeTo(subRepo, "master");
expectToHaveSubmoduleState(superRepo, "master",
"nested/subscribed-to-project", subHEAD);
}
private void deleteAllSubscriptions(TestRepository<?> repo, String branch)
throws Exception {
repo.git().fetch().setRemote("origin").call();