SubmoduleOp: Allow all branches to be subscribed
This eases the way of handling many different branches for the superproject subscription. As the superproject subscriptions are not yet in a release, we can still play around with them. When a user sees "refs = refs/heads/*:refs/heads/*" they cannot tell whether this is 1:1 matching or any match to any match without consulting the documentation. Differentiate the matching strategy by keys, such that we have "all = <refspec>" as well as "matching = <refspec>". The "all" key implies there is no interaction between the wildcards on the left and right side, e.g. all=refs/heads/*:refs/heads* indicates that any branch can be subscribed to any other branch in the given superproject. "matching" however substitutes the wildcard on the right with the captured value on the left. matching=refs/heads/*:refs/heads* allows a subscription of refs/heads/foo in the submodule to the refs/heads/foo in the superproject. Change-Id: I84d3a72c00f76570798880adf54ce56f974466ff
This commit is contained in:
@@ -86,7 +86,7 @@ the subscribe capabilities in the 'project.config' file:
|
|||||||
and add the following lines:
|
and add the following lines:
|
||||||
----
|
----
|
||||||
[allowSuperproject "<superproject>"]
|
[allowSuperproject "<superproject>"]
|
||||||
refs = <refspec>
|
matching = <refspec>
|
||||||
----
|
----
|
||||||
where the 'superproject' should be the exact project name of the superproject.
|
where the 'superproject' should be the exact project name of the superproject.
|
||||||
The refspec defines which branches of the submodule are allowed to be
|
The refspec defines which branches of the submodule are allowed to be
|
||||||
@@ -104,7 +104,7 @@ The configuration is inherited from parent projects, such that you can have
|
|||||||
a configuration in the "All-Projects" project like:
|
a configuration in the "All-Projects" project like:
|
||||||
----
|
----
|
||||||
[allowSuperproject "my-only-superproject"]
|
[allowSuperproject "my-only-superproject"]
|
||||||
refs = refs/heads/*:refs/heads/*
|
matching = refs/heads/*:refs/heads/*
|
||||||
----
|
----
|
||||||
and then you don't have to worry about configuring the individual projects
|
and then you don't have to worry about configuring the individual projects
|
||||||
any more. Child projects cannot negate the parent's configuration.
|
any more. Child projects cannot negate the parent's configuration.
|
||||||
@@ -147,14 +147,17 @@ a `branch` field and a url pointing to this server.
|
|||||||
|
|
||||||
[[acl_refspec]]
|
[[acl_refspec]]
|
||||||
=== The RefSpec in the allowSuperproject section
|
=== The RefSpec in the allowSuperproject section
|
||||||
The RefSpec for defining the branch level access for subscriptions look similar
|
There are two options for specifying which branches can be subscribed
|
||||||
to Git style RefSpecs used for pushing in Git. Regular expressions
|
to. The most common is to set `allowSuperproject.<superproject>.matching`
|
||||||
as found in the ACL configuration are not supported. The most restrictive
|
to a Git-style refspec, which has the same syntax as the refspecs used
|
||||||
RefSpec is allowing one specific branch of the submodule to be subscribed
|
for pushing in Git. Regular expressions as found in the ACL configuration
|
||||||
to one specific branch of the superproject via:
|
are not supported.
|
||||||
|
|
||||||
|
The most restrictive refspec is allowing one specific branch of the
|
||||||
|
submodule to be subscribed to one specific branch of the superproject:
|
||||||
----
|
----
|
||||||
[allowSuperproject "<superproject>"]
|
[allowSuperproject "<superproject>"]
|
||||||
refs = refs/heads/<submodule-branch>:refs/heads/<superproject-branch>
|
matching = refs/heads/<submodule-branch>:refs/heads/<superproject-branch>
|
||||||
----
|
----
|
||||||
|
|
||||||
If you want to allow for a 1:1 mapping, i.e. 'master' maps to 'master',
|
If you want to allow for a 1:1 mapping, i.e. 'master' maps to 'master',
|
||||||
@@ -162,14 +165,24 @@ If you want to allow for a 1:1 mapping, i.e. 'master' maps to 'master',
|
|||||||
'stable':
|
'stable':
|
||||||
----
|
----
|
||||||
[allowSuperproject "<superproject>"]
|
[allowSuperproject "<superproject>"]
|
||||||
refs = refs/heads/*:refs/heads/*
|
matching = refs/heads/*:refs/heads/*
|
||||||
----
|
----
|
||||||
|
|
||||||
If you want to enable a branch to be subscribed to any other branch of
|
To allow all refs matching one pattern to subscribe to all refs
|
||||||
the superproject, omit the second part of the RefSpec:
|
matching another pattern, set `allowSuperproject.<superproject>.all`
|
||||||
|
to the patterns concatenated with a colon. For example, to make a
|
||||||
|
single branch available for subscription from all branches of the
|
||||||
|
superproject:
|
||||||
----
|
----
|
||||||
[allowSuperproject "<superproject>"]
|
[allowSuperproject "<superproject>"]
|
||||||
refs = refs/heads/<submodule-branch>
|
all = refs/heads/<submodule-branch>:refs/heads/*
|
||||||
|
----
|
||||||
|
|
||||||
|
To make all branches available for subscription from all branches of
|
||||||
|
the superproject:
|
||||||
|
----
|
||||||
|
[allowSuperproject "<superproject>"]
|
||||||
|
all = refs/heads/*:refs/heads/*
|
||||||
----
|
----
|
||||||
|
|
||||||
=== Subscription Limitations
|
=== Subscription Limitations
|
||||||
|
|||||||
@@ -130,18 +130,25 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
|
|||||||
return pushChangeTo(repo, "refs/heads/" + branch, "some change", "");
|
return pushChangeTo(repo, "refs/heads/" + branch, "some change", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void allowSubmoduleSubscription(String submodule, String subBranch,
|
protected void allowSubmoduleSubscription(String submodule,
|
||||||
String superproject, String superBranch) throws Exception {
|
String subBranch, String superproject, String superBranch, boolean match)
|
||||||
|
throws Exception {
|
||||||
Project.NameKey sub = new Project.NameKey(name(submodule));
|
Project.NameKey sub = new Project.NameKey(name(submodule));
|
||||||
Project.NameKey superName = new Project.NameKey(name(superproject));
|
Project.NameKey superName = new Project.NameKey(name(superproject));
|
||||||
try (MetaDataUpdate md = metaDataUpdateFactory.create(sub)) {
|
try (MetaDataUpdate md = metaDataUpdateFactory.create(sub)) {
|
||||||
md.setMessage("Added superproject subscription");
|
md.setMessage("Added superproject subscription");
|
||||||
ProjectConfig pc = ProjectConfig.read(md);
|
ProjectConfig pc = ProjectConfig.read(md);
|
||||||
SubscribeSection s = new SubscribeSection(superName);
|
SubscribeSection s = new SubscribeSection(superName);
|
||||||
|
String refspec;
|
||||||
if (superBranch == null) {
|
if (superBranch == null) {
|
||||||
s.addRefSpec(subBranch);
|
refspec = subBranch;
|
||||||
} else {
|
} else {
|
||||||
s.addRefSpec(subBranch + ":" + superBranch);
|
refspec = subBranch + ":" + superBranch;
|
||||||
|
}
|
||||||
|
if (match) {
|
||||||
|
s.addMatchingRefSpec(refspec);
|
||||||
|
} else {
|
||||||
|
s.addMultiMatchRefSpec(refspec);
|
||||||
}
|
}
|
||||||
pc.addSubscribeSection(s);
|
pc.addSubscribeSection(s);
|
||||||
ObjectId oldId = pc.getRevision();
|
ObjectId oldId = pc.getRevision();
|
||||||
@@ -151,6 +158,13 @@ public abstract class AbstractSubmoduleSubscription extends AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void allowMatchingSubmoduleSubscription(String submodule,
|
||||||
|
String subBranch, String superproject, String superBranch)
|
||||||
|
throws Exception {
|
||||||
|
allowSubmoduleSubscription(submodule, subBranch, superproject,
|
||||||
|
superBranch, true);
|
||||||
|
}
|
||||||
|
|
||||||
protected void createSubmoduleSubscription(TestRepository<?> repo, String branch,
|
protected void createSubmoduleSubscription(TestRepository<?> repo, String branch,
|
||||||
String subscribeToRepo, String subscribeToBranch) throws Exception {
|
String subscribeToRepo, String subscribeToBranch) throws Exception {
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionWithoutGlobalServerSetting() throws Exception {
|
public void testSubscriptionWithoutGlobalServerSetting() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
createSubmoduleSubscription(superRepo, "master",
|
createSubmoduleSubscription(superRepo, "master",
|
||||||
@@ -70,7 +70,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionToEmptyRepo() throws Exception {
|
public void testSubscriptionToEmptyRepo() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
createSubmoduleSubscription(superRepo, "master",
|
createSubmoduleSubscription(superRepo, "master",
|
||||||
@@ -87,7 +87,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionToExistingRepo() throws Exception {
|
public void testSubscriptionToExistingRepo() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -104,8 +104,8 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionWildcardACLForSingleBranch() throws Exception {
|
public void testSubscriptionWildcardACLForSingleBranch() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
// master is allowed to be subscribed to any superprojects branch:
|
// master is allowed to be subscribed to master branch only:
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", null);
|
"super-project", null);
|
||||||
// create 'branch':
|
// create 'branch':
|
||||||
pushChangeTo(superRepo, "branch");
|
pushChangeTo(superRepo, "branch");
|
||||||
@@ -120,14 +120,14 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
|
|
||||||
expectToHaveSubmoduleState(superRepo, "master",
|
expectToHaveSubmoduleState(superRepo, "master",
|
||||||
"subscribed-to-project", subHEAD);
|
"subscribed-to-project", subHEAD);
|
||||||
expectToHaveSubmoduleState(superRepo, "branch",
|
assertThat(hasSubmodule(superRepo, "branch",
|
||||||
"subscribed-to-project", subHEAD);
|
"subscribed-to-project")).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSubscriptionWildcardACLForMissingProject() throws Exception {
|
public void testSubscriptionWildcardACLForMissingProject() throws Exception {
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
||||||
"not-existing-super-project", "refs/heads/*");
|
"not-existing-super-project", "refs/heads/*");
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionWildcardACLForMissingBranch() throws Exception {
|
public void testSubscriptionWildcardACLForMissingBranch() throws Exception {
|
||||||
createProjectWithPush("super-project");
|
createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
||||||
"super-project", "refs/heads/*");
|
"super-project", "refs/heads/*");
|
||||||
pushChangeTo(subRepo, "foo");
|
pushChangeTo(subRepo, "foo");
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionWildcardACLForMissingGitmodules() throws Exception {
|
public void testSubscriptionWildcardACLForMissingGitmodules() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
||||||
"super-project", "refs/heads/*");
|
"super-project", "refs/heads/*");
|
||||||
pushChangeTo(superRepo, "master");
|
pushChangeTo(superRepo, "master");
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -156,7 +156,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
// any branch is allowed to be subscribed to the same superprojects branch:
|
// any branch is allowed to be subscribed to the same superprojects branch:
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
||||||
"super-project", "refs/heads/*");
|
"super-project", "refs/heads/*");
|
||||||
|
|
||||||
// create 'branch' in both repos:
|
// create 'branch' in both repos:
|
||||||
@@ -188,12 +188,53 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
"subscribed-to-project", subHEAD3);
|
"subscribed-to-project", subHEAD3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriptionWildcardACLForManyBranches() throws Exception {
|
||||||
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
|
|
||||||
|
// Any branch is allowed to be subscribed to any superproject branch:
|
||||||
|
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/*",
|
||||||
|
"super-project", null, false);
|
||||||
|
pushChangeTo(superRepo, "branch");
|
||||||
|
pushChangeTo(subRepo, "another-branch");
|
||||||
|
createSubmoduleSubscription(superRepo, "branch",
|
||||||
|
"subscribed-to-project", "another-branch");
|
||||||
|
ObjectId subHEAD = pushChangeTo(subRepo, "another-branch");
|
||||||
|
expectToHaveSubmoduleState(superRepo, "branch",
|
||||||
|
"subscribed-to-project", subHEAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSubscriptionWildcardACLOneToManyBranches() throws Exception {
|
||||||
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
|
|
||||||
|
// Any branch is allowed to be subscribed to any superproject branch:
|
||||||
|
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
|
"super-project", "refs/heads/*", false);
|
||||||
|
pushChangeTo(superRepo, "branch");
|
||||||
|
createSubmoduleSubscription(superRepo, "branch",
|
||||||
|
"subscribed-to-project", "master");
|
||||||
|
ObjectId subHEAD = pushChangeTo(subRepo, "master");
|
||||||
|
expectToHaveSubmoduleState(superRepo, "branch",
|
||||||
|
"subscribed-to-project", subHEAD);
|
||||||
|
|
||||||
|
createSubmoduleSubscription(superRepo, "branch",
|
||||||
|
"subscribed-to-project", "branch");
|
||||||
|
pushChangeTo(subRepo, "branch");
|
||||||
|
|
||||||
|
// no change expected, as only master is subscribed:
|
||||||
|
expectToHaveSubmoduleState(superRepo, "branch",
|
||||||
|
"subscribed-to-project", subHEAD);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@GerritConfig(name = "submodule.verboseSuperprojectUpdate", value = "false")
|
@GerritConfig(name = "submodule.verboseSuperprojectUpdate", value = "false")
|
||||||
public void testSubmoduleShortCommitMessage() throws Exception {
|
public void testSubmoduleShortCommitMessage() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -220,7 +261,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubmoduleSubjectCommitMessage() throws Exception {
|
public void testSubmoduleSubjectCommitMessage() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -248,7 +289,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubmoduleCommitMessage() throws Exception {
|
public void testSubmoduleCommitMessage() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -276,7 +317,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionUnsubscribe() throws Exception {
|
public void testSubscriptionUnsubscribe() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -303,7 +344,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
throws Exception {
|
throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -329,7 +370,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionToDifferentBranches() throws Exception {
|
public void testSubscriptionToDifferentBranches() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/foo",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/foo",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
createSubmoduleSubscription(superRepo, "master",
|
createSubmoduleSubscription(superRepo, "master",
|
||||||
@@ -345,9 +386,9 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testBranchCircularSubscription() throws Exception {
|
public void testBranchCircularSubscription() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("super-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("super-project", "refs/heads/master",
|
||||||
"subscribed-to-project", "refs/heads/master");
|
"subscribed-to-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -370,9 +411,9 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
|
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("super-project", "refs/heads/dev",
|
allowMatchingSubmoduleSubscription("super-project", "refs/heads/dev",
|
||||||
"subscribed-to-project", "refs/heads/dev");
|
"subscribed-to-project", "refs/heads/dev");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -414,7 +455,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionFailOnWrongProjectACL() throws Exception {
|
public void testSubscriptionFailOnWrongProjectACL() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"wrong-super-project", "refs/heads/master");
|
"wrong-super-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -429,7 +470,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testSubscriptionFailOnWrongBranchACL() throws Exception {
|
public void testSubscriptionFailOnWrongBranchACL() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/wrong-branch");
|
"super-project", "refs/heads/wrong-branch");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -448,7 +489,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project",
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project",
|
||||||
new Project.NameKey(name("config-repo2")));
|
new Project.NameKey(name("config-repo2")));
|
||||||
allowSubmoduleSubscription("config-repo", "refs/heads/*",
|
allowMatchingSubmoduleSubscription("config-repo", "refs/heads/*",
|
||||||
"super-project", "refs/heads/*");
|
"super-project", "refs/heads/*");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -463,7 +504,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
public void testAllowedButNotSubscribed() throws Exception {
|
public void testAllowedButNotSubscribed() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
@@ -490,7 +531,7 @@ public class SubmoduleSubscriptionsIT extends AbstractSubmoduleSubscription {
|
|||||||
TestRepository<?> subRepo = createProjectWithPush(
|
TestRepository<?> subRepo = createProjectWithPush(
|
||||||
"nested/subscribed-to-project");
|
"nested/subscribed-to-project");
|
||||||
// master is allowed to be subscribed to any superprojects branch:
|
// master is allowed to be subscribed to any superprojects branch:
|
||||||
allowSubmoduleSubscription("nested/subscribed-to-project",
|
allowMatchingSubmoduleSubscription("nested/subscribed-to-project",
|
||||||
"refs/heads/master", "super-project", null);
|
"refs/heads/master", "super-project", null);
|
||||||
|
|
||||||
pushChangeTo(subRepo, "master");
|
pushChangeTo(subRepo, "master");
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
public void testSubscriptionUpdateOfManyChanges() throws Exception {
|
public void testSubscriptionUpdateOfManyChanges() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||||
@@ -113,7 +113,7 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
public void testSubscriptionUpdateIncludingChangeInSuperproject() throws Exception {
|
public void testSubscriptionUpdateIncludingChangeInSuperproject() throws Exception {
|
||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
createSubmoduleSubscription(superRepo, "master", "subscribed-to-project", "master");
|
||||||
@@ -181,11 +181,11 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
TestRepository<?> sub2 = createProjectWithPush("sub2");
|
TestRepository<?> sub2 = createProjectWithPush("sub2");
|
||||||
TestRepository<?> sub3 = createProjectWithPush("sub3");
|
TestRepository<?> sub3 = createProjectWithPush("sub3");
|
||||||
|
|
||||||
allowSubmoduleSubscription("sub1", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("sub1", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("sub2", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("sub2", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("sub3", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("sub3", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
@@ -227,7 +227,7 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> sub = createProjectWithPush("sub");
|
TestRepository<?> sub = createProjectWithPush("sub");
|
||||||
|
|
||||||
allowSubmoduleSubscription("sub", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("sub", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
Config config = new Config();
|
Config config = new Config();
|
||||||
@@ -261,7 +261,7 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
TestRepository<?> sub = createProjectWithPush("sub");
|
TestRepository<?> sub = createProjectWithPush("sub");
|
||||||
TestRepository<?> standAlone = createProjectWithPush("standalone");
|
TestRepository<?> standAlone = createProjectWithPush("standalone");
|
||||||
|
|
||||||
allowSubmoduleSubscription("sub", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("sub", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
|
|
||||||
createSubmoduleSubscription(superRepo, "master", "sub", "master");
|
createSubmoduleSubscription(superRepo, "master", "sub", "master");
|
||||||
@@ -301,9 +301,9 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
TestRepository<?> midRepo = createProjectWithPush("mid-project");
|
TestRepository<?> midRepo = createProjectWithPush("mid-project");
|
||||||
TestRepository<?> bottomRepo = createProjectWithPush("bottom-project");
|
TestRepository<?> bottomRepo = createProjectWithPush("bottom-project");
|
||||||
|
|
||||||
allowSubmoduleSubscription("mid-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("mid-project", "refs/heads/master",
|
||||||
"top-project", "refs/heads/master");
|
"top-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("bottom-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("bottom-project", "refs/heads/master",
|
||||||
"mid-project", "refs/heads/master");
|
"mid-project", "refs/heads/master");
|
||||||
|
|
||||||
createSubmoduleSubscription(topRepo, "master", "mid-project", "master");
|
createSubmoduleSubscription(topRepo, "master", "mid-project", "master");
|
||||||
@@ -332,11 +332,11 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
TestRepository<?> midRepo = createProjectWithPush("mid-project");
|
TestRepository<?> midRepo = createProjectWithPush("mid-project");
|
||||||
TestRepository<?> bottomRepo = createProjectWithPush("bottom-project");
|
TestRepository<?> bottomRepo = createProjectWithPush("bottom-project");
|
||||||
|
|
||||||
allowSubmoduleSubscription("mid-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("mid-project", "refs/heads/master",
|
||||||
"top-project", "refs/heads/master");
|
"top-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("bottom-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("bottom-project", "refs/heads/master",
|
||||||
"mid-project", "refs/heads/master");
|
"mid-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("bottom-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("bottom-project", "refs/heads/master",
|
||||||
"top-project", "refs/heads/master");
|
"top-project", "refs/heads/master");
|
||||||
|
|
||||||
createSubmoduleSubscription(midRepo, "master", "bottom-project", "master");
|
createSubmoduleSubscription(midRepo, "master", "bottom-project", "master");
|
||||||
@@ -373,11 +373,11 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
createSubmoduleSubscription(topRepo, "master", "mid-project", "master");
|
createSubmoduleSubscription(topRepo, "master", "mid-project", "master");
|
||||||
createSubmoduleSubscription(bottomRepo, "master", "top-project", "master");
|
createSubmoduleSubscription(bottomRepo, "master", "top-project", "master");
|
||||||
|
|
||||||
allowSubmoduleSubscription("bottom-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("bottom-project", "refs/heads/master",
|
||||||
"mid-project", "refs/heads/master");
|
"mid-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("mid-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("mid-project", "refs/heads/master",
|
||||||
"top-project", "refs/heads/master");
|
"top-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("top-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("top-project", "refs/heads/master",
|
||||||
"bottom-project", "refs/heads/master");
|
"bottom-project", "refs/heads/master");
|
||||||
|
|
||||||
ObjectId bottomMasterHead =
|
ObjectId bottomMasterHead =
|
||||||
@@ -401,9 +401,9 @@ public class SubmoduleSubscriptionsWholeTopicMergeIT
|
|||||||
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
TestRepository<?> superRepo = createProjectWithPush("super-project");
|
||||||
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
TestRepository<?> subRepo = createProjectWithPush("subscribed-to-project");
|
||||||
|
|
||||||
allowSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
allowMatchingSubmoduleSubscription("subscribed-to-project", "refs/heads/master",
|
||||||
"super-project", "refs/heads/master");
|
"super-project", "refs/heads/master");
|
||||||
allowSubmoduleSubscription("super-project", "refs/heads/dev",
|
allowMatchingSubmoduleSubscription("super-project", "refs/heads/dev",
|
||||||
"subscribed-to-project", "refs/heads/dev");
|
"subscribed-to-project", "refs/heads/dev");
|
||||||
|
|
||||||
pushChangeTo(subRepo, "dev");
|
pushChangeTo(subRepo, "dev");
|
||||||
|
|||||||
@@ -29,20 +29,28 @@ import java.util.List;
|
|||||||
@GwtIncompatible("Unemulated org.eclipse.jgit.transport.RefSpec")
|
@GwtIncompatible("Unemulated org.eclipse.jgit.transport.RefSpec")
|
||||||
public class SubscribeSection {
|
public class SubscribeSection {
|
||||||
|
|
||||||
private final List<RefSpec> refSpecs;
|
private final List<RefSpec> multiMatchRefSpecs;
|
||||||
|
private final List<RefSpec> matchingRefSpecs;
|
||||||
private final Project.NameKey project;
|
private final Project.NameKey project;
|
||||||
|
|
||||||
public SubscribeSection(Project.NameKey p) {
|
public SubscribeSection(Project.NameKey p) {
|
||||||
project = p;
|
project = p;
|
||||||
refSpecs = new ArrayList<>();
|
matchingRefSpecs = new ArrayList<>();
|
||||||
|
multiMatchRefSpecs = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRefSpec(RefSpec spec) {
|
public void addMatchingRefSpec(RefSpec spec) {
|
||||||
refSpecs.add(spec);
|
matchingRefSpecs.add(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRefSpec(String spec) {
|
public void addMatchingRefSpec(String spec) {
|
||||||
refSpecs.add(new RefSpec(spec));
|
RefSpec r = new RefSpec(spec);
|
||||||
|
matchingRefSpecs.add(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMultiMatchRefSpec(String spec) {
|
||||||
|
RefSpec r = new RefSpec(spec, RefSpec.WildcardMode.ALLOW_MISMATCH);
|
||||||
|
multiMatchRefSpecs.add(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project.NameKey getProject() {
|
public Project.NameKey getProject() {
|
||||||
@@ -57,7 +65,12 @@ public class SubscribeSection {
|
|||||||
* @return if the branch could trigger a superproject update
|
* @return if the branch could trigger a superproject update
|
||||||
*/
|
*/
|
||||||
public boolean appliesTo(Branch.NameKey branch) {
|
public boolean appliesTo(Branch.NameKey branch) {
|
||||||
for (RefSpec r : refSpecs) {
|
for (RefSpec r : matchingRefSpecs) {
|
||||||
|
if (r.matchSource(branch.get())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (RefSpec r : multiMatchRefSpecs) {
|
||||||
if (r.matchSource(branch.get())) {
|
if (r.matchSource(branch.get())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -65,8 +78,12 @@ public class SubscribeSection {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<RefSpec> getRefSpecs() {
|
public Collection<RefSpec> getMatchingRefSpecs() {
|
||||||
return Collections.unmodifiableCollection(refSpecs);
|
return Collections.unmodifiableCollection(matchingRefSpecs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<RefSpec> getMultiMatchRefSpecs() {
|
||||||
|
return Collections.unmodifiableCollection(multiMatchRefSpecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,10 +91,19 @@ public class SubscribeSection {
|
|||||||
StringBuilder ret = new StringBuilder();
|
StringBuilder ret = new StringBuilder();
|
||||||
ret.append("[SubscribeSection, project=");
|
ret.append("[SubscribeSection, project=");
|
||||||
ret.append(project);
|
ret.append(project);
|
||||||
ret.append(", refs=[");
|
if (!matchingRefSpecs.isEmpty()) {
|
||||||
for (RefSpec r : refSpecs) {
|
ret.append(", matching=[");
|
||||||
ret.append(r.toString());
|
for (RefSpec r : matchingRefSpecs) {
|
||||||
ret.append(", ");
|
ret.append(r.toString());
|
||||||
|
ret.append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!multiMatchRefSpecs.isEmpty()) {
|
||||||
|
ret.append(", all=[");
|
||||||
|
for (RefSpec r : multiMatchRefSpecs) {
|
||||||
|
ret.append(r.toString());
|
||||||
|
ret.append(", ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ret.append("]");
|
ret.append("]");
|
||||||
return ret.toString();
|
return ret.toString();
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
|||||||
private static final String KEY_STATE = "state";
|
private static final String KEY_STATE = "state";
|
||||||
|
|
||||||
private static final String SUBSCRIBE_SECTION = "allowSuperproject";
|
private static final String SUBSCRIBE_SECTION = "allowSuperproject";
|
||||||
private static final String SUBSCRIBE_REFS = "refs";
|
private static final String SUBSCRIBE_MATCH_REFS = "matching";
|
||||||
|
private static final String SUBSCRIBE_MULTI_MATCH_REFS = "all";
|
||||||
|
|
||||||
private static final String DASHBOARD = "dashboard";
|
private static final String DASHBOARD = "dashboard";
|
||||||
private static final String KEY_DEFAULT = "default";
|
private static final String KEY_DEFAULT = "default";
|
||||||
@@ -848,8 +849,12 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
|||||||
Project.NameKey p = new Project.NameKey(projectName);
|
Project.NameKey p = new Project.NameKey(projectName);
|
||||||
SubscribeSection ss = new SubscribeSection(p);
|
SubscribeSection ss = new SubscribeSection(p);
|
||||||
for (String s : rc.getStringList(SUBSCRIBE_SECTION,
|
for (String s : rc.getStringList(SUBSCRIBE_SECTION,
|
||||||
projectName, SUBSCRIBE_REFS)) {
|
projectName, SUBSCRIBE_MULTI_MATCH_REFS)) {
|
||||||
ss.addRefSpec(s);
|
ss.addMultiMatchRefSpec(s);
|
||||||
|
}
|
||||||
|
for (String s : rc.getStringList(SUBSCRIBE_SECTION,
|
||||||
|
projectName, SUBSCRIBE_MATCH_REFS)) {
|
||||||
|
ss.addMatchingRefSpec(s);
|
||||||
}
|
}
|
||||||
subscribeSections.put(p, ss);
|
subscribeSections.put(p, ss);
|
||||||
}
|
}
|
||||||
@@ -1238,8 +1243,13 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
|||||||
private void saveSubscribeSections(Config rc) {
|
private void saveSubscribeSections(Config rc) {
|
||||||
for (Project.NameKey p : subscribeSections.keySet()) {
|
for (Project.NameKey p : subscribeSections.keySet()) {
|
||||||
SubscribeSection s = subscribeSections.get(p);
|
SubscribeSection s = subscribeSections.get(p);
|
||||||
for (RefSpec r : s.getRefSpecs()) {
|
for (RefSpec r : s.getMatchingRefSpecs()) {
|
||||||
rc.setString(SUBSCRIBE_SECTION, p.get(), SUBSCRIBE_REFS, r.toString());
|
rc.setString(SUBSCRIBE_SECTION, p.get(),
|
||||||
|
SUBSCRIBE_MATCH_REFS, r.toString());
|
||||||
|
}
|
||||||
|
for (RefSpec r : s.getMultiMatchRefSpecs()) {
|
||||||
|
rc.setString(SUBSCRIBE_SECTION, p.get(),
|
||||||
|
SUBSCRIBE_MULTI_MATCH_REFS, r.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -222,33 +223,50 @@ public class SubmoduleOp {
|
|||||||
|
|
||||||
private Collection<Branch.NameKey> getDestinationBranches(Branch.NameKey src,
|
private Collection<Branch.NameKey> getDestinationBranches(Branch.NameKey src,
|
||||||
SubscribeSection s) throws IOException {
|
SubscribeSection s) throws IOException {
|
||||||
Collection<Branch.NameKey> ret = new ArrayList<>();
|
Collection<Branch.NameKey> ret = new HashSet<>();
|
||||||
logDebug("Inspecting SubscribeSection " + s);
|
logDebug("Inspecting SubscribeSection " + s);
|
||||||
for (RefSpec r : s.getRefSpecs()) {
|
for (RefSpec r : s.getMatchingRefSpecs()) {
|
||||||
logDebug("Inspecting ref " + r);
|
logDebug("Inspecting [matching] ref " + r);
|
||||||
if (r.matchSource(src.get())) {
|
if (!r.matchSource(src.get())) {
|
||||||
if (r.getDestination() == null) {
|
continue;
|
||||||
// no need to care for wildcard, as we matched already
|
}
|
||||||
OpenRepo or;
|
if (r.isWildcard()) {
|
||||||
try {
|
// refs/heads/*[:refs/somewhere/*]
|
||||||
or = orm.openRepo(s.getProject(), false);
|
ret.add(new Branch.NameKey(s.getProject(),
|
||||||
} catch (NoSuchProjectException e) {
|
r.expandFromSource(src.get()).getDestination()));
|
||||||
// A project listed a non existent project to be allowed
|
} else {
|
||||||
// to subscribe to it. Allow this for now.
|
// e.g. refs/heads/master[:refs/heads/stable]
|
||||||
continue;
|
String dest = r.getDestination();
|
||||||
}
|
if (dest == null) {
|
||||||
|
dest = r.getSource();
|
||||||
|
}
|
||||||
|
ret.add(new Branch.NameKey(s.getProject(), dest));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Ref ref : or.repo.getRefDatabase().getRefs(
|
for (RefSpec r : s.getMultiMatchRefSpecs()) {
|
||||||
RefNames.REFS_HEADS).values()) {
|
logDebug("Inspecting [all] ref " + r);
|
||||||
ret.add(new Branch.NameKey(s.getProject(), ref.getName()));
|
if (!r.matchSource(src.get())) {
|
||||||
}
|
continue;
|
||||||
} else if (r.isWildcard()) {
|
}
|
||||||
// refs/heads/*:refs/heads/*
|
OpenRepo or;
|
||||||
ret.add(new Branch.NameKey(s.getProject(),
|
try {
|
||||||
r.expandFromSource(src.get()).getDestination()));
|
or = orm.openRepo(s.getProject(), false);
|
||||||
} else {
|
} catch (NoSuchProjectException e) {
|
||||||
// e.g. refs/heads/master:refs/heads/stable
|
// A project listed a non existent project to be allowed
|
||||||
ret.add(new Branch.NameKey(s.getProject(), r.getDestination()));
|
// to subscribe to it. Allow this for now, i.e. no exception is
|
||||||
|
// thrown.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Ref ref : or.repo.getRefDatabase().getRefs(
|
||||||
|
RefNames.REFS_HEADS).values()) {
|
||||||
|
if (r.getDestination() != null && !r.matchDestination(ref.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Branch.NameKey b = new Branch.NameKey(s.getProject(), ref.getName());
|
||||||
|
if (!ret.contains(b)) {
|
||||||
|
ret.add(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,10 +79,10 @@ public class Schema_120 extends SchemaVersion {
|
|||||||
}
|
}
|
||||||
RefSpec newRefSpec = new RefSpec(subbranch.get() + ":" + superBranch.get());
|
RefSpec newRefSpec = new RefSpec(subbranch.get() + ":" + superBranch.get());
|
||||||
|
|
||||||
if (!s.getRefSpecs().contains(newRefSpec)) {
|
if (!s.getMatchingRefSpecs().contains(newRefSpec)) {
|
||||||
// For the migration we use only exact RefSpecs, we're not trying to
|
// For the migration we use only exact RefSpecs, we're not trying to
|
||||||
// generalize it.
|
// generalize it.
|
||||||
s.addRefSpec(newRefSpec);
|
s.addMatchingRefSpec(newRefSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.commit(md);
|
pc.commit(md);
|
||||||
|
|||||||
Reference in New Issue
Block a user