Search in sources :

Example 46 with BranchNameKey

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);
}
Also used : Project(com.google.gerrit.entities.Project) BranchNameKey(com.google.gerrit.entities.BranchNameKey) SubmoduleSubscription(com.google.gerrit.entities.SubmoduleSubscription) BranchNameKey(com.google.gerrit.entities.BranchNameKey) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 47 with BranchNameKey

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());
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 48 with BranchNameKey

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);
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) IdString(com.google.gerrit.extensions.restapi.IdString) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 49 with BranchNameKey

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());
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) BooleanCondition(com.google.gerrit.extensions.conditions.BooleanCondition) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 50 with BranchNameKey

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());
}
Also used : BranchNameKey(com.google.gerrit.entities.BranchNameKey) BooleanCondition(com.google.gerrit.extensions.conditions.BooleanCondition) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

BranchNameKey (com.google.gerrit.entities.BranchNameKey)75 Test (org.junit.Test)48 Project (com.google.gerrit.entities.Project)26 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)25 Config (org.eclipse.jgit.lib.Config)19 SubmoduleSubscription (com.google.gerrit.entities.SubmoduleSubscription)18 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)16 RevCommit (org.eclipse.jgit.revwalk.RevCommit)16 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)15 AuthException (com.google.gerrit.extensions.restapi.AuthException)13 Change (com.google.gerrit.entities.Change)12 IOException (java.io.IOException)11 ObjectId (org.eclipse.jgit.lib.ObjectId)11 StorageException (com.google.gerrit.exceptions.StorageException)10 ChangeData (com.google.gerrit.server.query.change.ChangeData)9 Repository (org.eclipse.jgit.lib.Repository)9 PatchSet (com.google.gerrit.entities.PatchSet)8 CodeReviewCommit (com.google.gerrit.server.git.CodeReviewCommit)8 HashMap (java.util.HashMap)7 Ref (org.eclipse.jgit.lib.Ref)7