use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.
the class UpdateOrderCalculator method addAllSubmoduleProjects.
private void addAllSubmoduleProjects(Project.NameKey project, LinkedHashSet<Project.NameKey> current, LinkedHashSet<Project.NameKey> projects) throws SubmoduleConflictException {
if (current.contains(project)) {
throw new SubmoduleConflictException("Project level circular subscriptions detected: " + CircularPathFinder.printCircularPath(current, project));
}
if (projects.contains(project)) {
return;
}
current.add(project);
Set<Project.NameKey> subprojects = new HashSet<>();
for (BranchNameKey branch : subscriptionGraph.getAffectedSuperBranches(project)) {
Collection<SubmoduleSubscription> subscriptions = subscriptionGraph.getSubscriptions(branch);
for (SubmoduleSubscription s : subscriptions) {
subprojects.add(s.getSubmodule().project());
}
}
for (Project.NameKey p : subprojects) {
addAllSubmoduleProjects(p, current, projects);
}
current.remove(project);
projects.add(project);
}
use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.
the class SubmoduleCommitsTest method amendGitlinksCommit_subprojectMoved.
@Test
public void amendGitlinksCommit_subprojectMoved() throws Exception {
createRepo(subProject, MASTER);
createRepo(superProject, MASTER);
when(mockProjectCache.get(any())).thenReturn(Optional.of(mockProjectState));
mergeOpRepoManager = new MergeOpRepoManager(repoManager, mockProjectCache, null, null);
ObjectId subprojectCommit = getTip(subProject, MASTER);
CodeReviewCommit superprojectTip = directUpdateSubmodule(superProject, MASTER, Project.nameKey("dir-x"), subprojectCommit);
assertThat(readGitLink(superProject, superprojectTip, "dir-x")).isEqualTo(subprojectCommit);
RevCommit newSubprojectCommit = addCommit(subProject, MASTER);
BranchNameKey superBranch = BranchNameKey.create(superProject, MASTER);
BranchNameKey subBranch = BranchNameKey.create(subProject, MASTER);
SubmoduleSubscription ss = new SubmoduleSubscription(superBranch, subBranch, "dir-x");
SubmoduleCommits helper = new SubmoduleCommits(mergeOpRepoManager, ident, new Config());
CodeReviewCommit amendedCommit = helper.amendGitlinksCommit(BranchNameKey.create(superProject, MASTER), superprojectTip, ImmutableList.of(ss));
assertThat(amendedCommit.getParent(0)).isEqualTo(superprojectTip.getParent(0));
assertThat(readGitLink(superProject, amendedCommit, "dir-x")).isEqualTo(newSubprojectCommit);
}
use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method followMasterBranch.
@Test
public void followMasterBranch() throws Exception {
Project.NameKey p = Project.nameKey("proj");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"a\"]\n" + "path = localpath-to-a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = master\n");
BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, BranchNameKey.create(p, "master"), "localpath-to-a"));
assertThat(res).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method withAnInvalidSection.
@Test
public void withAnInvalidSection() throws Exception {
Project.NameKey p1 = Project.nameKey("a");
Project.NameKey p2 = Project.nameKey("b");
Project.NameKey p3 = Project.nameKey("d");
Project.NameKey p4 = Project.nameKey("e");
Config cfg = new Config();
cfg.fromText("\n" + "[submodule \"a\"]\n" + " path = a\n" + " url = ssh://localhost/" + p1.get() + "\n" + " branch = .\n" + "[submodule \"b\"]\n" + // path missing
" url = http://localhost:80/" + p2.get() + "\n" + " branch = master\n" + "[submodule \"c\"]\n" + " path = c\n" + // url missing
" branch = .\n" + "[submodule \"d\"]\n" + " path = d-parent/the-d-folder\n" + " url = ssh://localhost/" + p3.get() + "\n" + // branch missing
"[submodule \"e\"]\n" + " path = e\n" + " url = ssh://localhost/" + p4.get() + "\n" + " branch = refs/heads/master\n");
BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
Set<SubmoduleSubscription> expected = Sets.newHashSet(new SubmoduleSubscription(targetBranch, BranchNameKey.create(p1, "master"), "a"), new SubmoduleSubscription(targetBranch, BranchNameKey.create(p4, "master"), "e"));
assertThat(res).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.entities.SubmoduleSubscription in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method withSectionToOtherServer.
@Test
public void withSectionToOtherServer() throws Exception {
Project.NameKey p1 = Project.nameKey("a");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"a\"]" + "path = a" + "url = ssh://non-localhost/" + p1.get() + "\n" + "branch = .");
BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("project"), "master");
Set<SubmoduleSubscription> res = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch).parseAllSections();
assertThat(res).isEmpty();
}
Aggregations