use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method withSlashesInProjectName.
@Test
public void withSlashesInProjectName() throws Exception {
Project.NameKey p = Project.nameKey("project/with/slashes/a");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"project/with/slashes/a\"]\n" + "path = a\n" + "url = http://localhost:80/" + 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"), "a"));
assertThat(res).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method withMoreSections.
@Test
public void withMoreSections() throws Exception {
Project.NameKey p1 = Project.nameKey("a");
Project.NameKey p2 = Project.nameKey("b");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"a\"]\n" + " path = a\n" + " url = ssh://localhost/" + p1.get() + "\n" + " branch = .\n" + "[submodule \"b\"]\n" + " path = b\n" + " url = http://localhost:80/" + p2.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(p1, "master"), "a"), new SubmoduleSubscription(targetBranch, BranchNameKey.create(p2, "master"), "b"));
assertThat(res).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method withDeepRelativeURI.
@Test
public void withDeepRelativeURI() throws Exception {
Project.NameKey p1 = Project.nameKey("a");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ../../" + p1.get() + "\n" + "branch = master\n");
BranchNameKey targetBranch = BranchNameKey.create(Project.nameKey("nested/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"));
assertThat(res).containsExactlyElementsIn(expected);
}
use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class SubmoduleSectionParserTest method followMatchingBranch.
@Test
public void followMatchingBranch() throws Exception {
Project.NameKey p = Project.nameKey("a");
Config cfg = new Config();
cfg.fromText("" + "[submodule \"a\"]\n" + "path = a\n" + "url = ssh://localhost/" + p.get() + "\n" + "branch = .\n");
BranchNameKey targetBranch1 = BranchNameKey.create(Project.nameKey("project"), "master");
Set<SubmoduleSubscription> res1 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch1).parseAllSections();
Set<SubmoduleSubscription> expected1 = Sets.newHashSet(new SubmoduleSubscription(targetBranch1, BranchNameKey.create(p, "master"), "a"));
assertThat(res1).containsExactlyElementsIn(expected1);
BranchNameKey targetBranch2 = BranchNameKey.create(Project.nameKey("project"), "somebranch");
Set<SubmoduleSubscription> res2 = new SubmoduleSectionParser(cfg, THIS_SERVER, targetBranch2).parseAllSections();
Set<SubmoduleSubscription> expected2 = Sets.newHashSet(new SubmoduleSubscription(targetBranch2, BranchNameKey.create(p, "somebranch"), "a"));
assertThat(res2).containsExactlyElementsIn(expected2);
}
use of com.google.gerrit.entities.Project in project gerrit by GerritCodeReview.
the class VisibleChangesCache method visibleChangesBySearch.
private void visibleChangesBySearch() throws PermissionBackendException {
visibleChanges = new HashMap<>();
Project.NameKey project = projectState.getNameKey();
try {
for (ChangeData cd : changeCache.getChangeData(project)) {
if (!projectState.statePermitsRead()) {
continue;
}
if (permissionBackendForProject.change(cd).test(ChangePermission.READ)) {
visibleChanges.put(cd.getId(), cd.change().getDest());
}
}
} catch (StorageException e) {
logger.atSevere().withCause(e).log("Cannot load changes for project %s, assuming no changes are visible", project);
}
}
Aggregations