use of com.google.gerrit.entities.BranchNameKey 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.BranchNameKey in project gerrit by GerritCodeReview.
the class CreateBranchIT method createBranchLeadingSlashesAreRemoved.
@Test
public void createBranchLeadingSlashesAreRemoved() throws Exception {
BranchNameKey expectedNameKey = BranchNameKey.create(project, "test");
// check that the branch doesn't exist yet
assertThrows(ResourceNotFoundException.class, () -> gApi.projects().name(project.get()).branch(expectedNameKey.branch()).get());
// create the branch, but include leading slashes in the branch name,
// when creating the branch ensure that the branch name in the URL matches the branch name in
// the input (if there is a mismatch the creation request is rejected)
BranchInput branchInput = new BranchInput();
branchInput.ref = "////" + expectedNameKey.shortName();
gApi.projects().name(project.get()).branch(branchInput.ref).create(branchInput);
// verify that the branch was created without the leading slashes in the name
assertThat(gApi.projects().name(project.get()).branch(expectedNameKey.branch()).get().ref).isEqualTo(expectedNameKey.branch());
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class DeleteBranchIT method deleteMetaBranch.
@Test
public void deleteMetaBranch() throws Exception {
String metaRef = RefNames.REFS_META + "foo";
projectOperations.project(project).forUpdate().add(allow(Permission.READ).ref(metaRef).group(REGISTERED_USERS)).add(allow(Permission.CREATE).ref(metaRef).group(REGISTERED_USERS)).add(allow(Permission.PUSH).ref(metaRef).group(REGISTERED_USERS)).update();
BranchNameKey metaBranch = BranchNameKey.create(project, metaRef);
branch(metaBranch).create(new BranchInput());
grantDelete();
assertDeleteByRestSucceeds(metaBranch, metaRef);
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class PermissionBackendConditionIT method refPermissions_differentResourceAndSameUserDoesNotEqual2.
@Test
public void refPermissions_differentResourceAndSameUserDoesNotEqual2() throws Exception {
BranchNameKey branch1 = BranchNameKey.create(project, "branch");
BranchNameKey branch2 = BranchNameKey.create(projectOperations.newProject().create(), "branch");
BooleanCondition cond1 = pb.user(user()).ref(branch1).testCond(RefPermission.READ);
BooleanCondition cond2 = pb.user(user()).ref(branch2).testCond(RefPermission.READ);
assertNotEquals(cond1, cond2);
assertNotEquals(cond1.hashCode(), cond2.hashCode());
}
use of com.google.gerrit.entities.BranchNameKey in project gerrit by GerritCodeReview.
the class PermissionBackendConditionIT method refPermissions_differentResourceAndSameUserDoesNotEqual.
@Test
public void refPermissions_differentResourceAndSameUserDoesNotEqual() throws Exception {
BranchNameKey branch1 = BranchNameKey.create(project, "branch");
BranchNameKey branch2 = BranchNameKey.create(project, "branch2");
BooleanCondition cond1 = pb.user(user()).ref(branch1).testCond(RefPermission.READ);
BooleanCondition cond2 = pb.user(user()).ref(branch2).testCond(RefPermission.READ);
assertNotEquals(cond1, cond2);
assertNotEquals(cond1.hashCode(), cond2.hashCode());
}
Aggregations