Search in sources :

Example 1 with NameKey

use of com.google.gerrit.reviewdb.client.Project.NameKey in project gerrit by GerritCodeReview.

the class RepositoryConfigTest method defaultSubmitTypeForStartWithFilter.

@Test
public void defaultSubmitTypeForStartWithFilter() {
    configureDefaultSubmitType("somePath/somePath/*", SubmitType.REBASE_IF_NECESSARY);
    configureDefaultSubmitType("somePath/*", SubmitType.CHERRY_PICK);
    configureDefaultSubmitType("*", SubmitType.MERGE_ALWAYS);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject"))).isEqualTo(SubmitType.MERGE_ALWAYS);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("somePath/someProject"))).isEqualTo(SubmitType.CHERRY_PICK);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("somePath/somePath/someProject"))).isEqualTo(SubmitType.REBASE_IF_NECESSARY);
}
Also used : NameKey(com.google.gerrit.reviewdb.client.Project.NameKey) Test(org.junit.Test)

Example 2 with NameKey

use of com.google.gerrit.reviewdb.client.Project.NameKey in project gerrit by GerritCodeReview.

the class RepositoryConfigTest method defaultSubmitTypeForStarFilter.

@Test
public void defaultSubmitTypeForStarFilter() {
    configureDefaultSubmitType("*", SubmitType.CHERRY_PICK);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject"))).isEqualTo(SubmitType.CHERRY_PICK);
    configureDefaultSubmitType("*", SubmitType.FAST_FORWARD_ONLY);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject"))).isEqualTo(SubmitType.FAST_FORWARD_ONLY);
    configureDefaultSubmitType("*", SubmitType.REBASE_IF_NECESSARY);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject"))).isEqualTo(SubmitType.REBASE_IF_NECESSARY);
    configureDefaultSubmitType("*", SubmitType.REBASE_ALWAYS);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject"))).isEqualTo(SubmitType.REBASE_ALWAYS);
}
Also used : NameKey(com.google.gerrit.reviewdb.client.Project.NameKey) Test(org.junit.Test)

Example 3 with NameKey

use of com.google.gerrit.reviewdb.client.Project.NameKey in project gerrit by GerritCodeReview.

the class RepositoryConfigTest method ownerGroupsForStartWithFilter.

@Test
public void ownerGroupsForStartWithFilter() {
    ImmutableList<String> ownerGroups1 = ImmutableList.of("group1");
    ImmutableList<String> ownerGroups2 = ImmutableList.of("group2");
    ImmutableList<String> ownerGroups3 = ImmutableList.of("group3");
    configureOwnerGroups("*", ownerGroups1);
    configureOwnerGroups("somePath/*", ownerGroups2);
    configureOwnerGroups("somePath/somePath/*", ownerGroups3);
    assertThat(repoCfg.getOwnerGroups(new NameKey("someProject"))).containsExactlyElementsIn(ownerGroups1);
    assertThat(repoCfg.getOwnerGroups(new NameKey("somePath/someProject"))).containsExactlyElementsIn(ownerGroups2);
    assertThat(repoCfg.getOwnerGroups(new NameKey("somePath/somePath/someProject"))).containsExactlyElementsIn(ownerGroups3);
}
Also used : NameKey(com.google.gerrit.reviewdb.client.Project.NameKey) Test(org.junit.Test)

Example 4 with NameKey

use of com.google.gerrit.reviewdb.client.Project.NameKey in project gerrit by GerritCodeReview.

the class RepositoryConfigTest method defaultSubmitTypeForSpecificFilter.

@Test
public void defaultSubmitTypeForSpecificFilter() {
    configureDefaultSubmitType("someProject", SubmitType.CHERRY_PICK);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("someOtherProject"))).isEqualTo(SubmitType.MERGE_IF_NECESSARY);
    assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject"))).isEqualTo(SubmitType.CHERRY_PICK);
}
Also used : NameKey(com.google.gerrit.reviewdb.client.Project.NameKey) Test(org.junit.Test)

Example 5 with NameKey

use of com.google.gerrit.reviewdb.client.Project.NameKey in project gerrit by GerritCodeReview.

the class Schema_108 method getOpenChangesByProject.

private SetMultimap<Project.NameKey, Change.Id> getOpenChangesByProject(ReviewDb db, UpdateUI ui) throws OrmException {
    SortedSet<NameKey> projects = repoManager.list();
    SortedSet<NameKey> nonExistentProjects = Sets.newTreeSet();
    SetMultimap<Project.NameKey, Change.Id> openByProject = MultimapBuilder.hashKeys().hashSetValues().build();
    for (Change c : db.changes().all()) {
        Status status = c.getStatus();
        if (status != null && status.isClosed()) {
            continue;
        }
        NameKey projectKey = c.getProject();
        if (!projects.contains(projectKey)) {
            nonExistentProjects.add(projectKey);
        } else {
            // The old "submitted" state is not supported anymore
            // (thus status is null) but it was an opened state and needs
            // to be migrated as such
            openByProject.put(projectKey, c.getId());
        }
    }
    if (!nonExistentProjects.isEmpty()) {
        ui.message("Detected open changes referring to the following non-existent projects:");
        ui.message(Joiner.on(", ").join(nonExistentProjects));
        ui.message("It is highly recommended to remove\n" + "the obsolete open changes, comments and patch-sets from your DB.\n");
    }
    return openByProject;
}
Also used : Status(com.google.gerrit.reviewdb.client.Change.Status) ObjectId(org.eclipse.jgit.lib.ObjectId) Change(com.google.gerrit.reviewdb.client.Change) NameKey(com.google.gerrit.reviewdb.client.Project.NameKey)

Aggregations

NameKey (com.google.gerrit.reviewdb.client.Project.NameKey)7 Test (org.junit.Test)6 Change (com.google.gerrit.reviewdb.client.Change)1 Status (com.google.gerrit.reviewdb.client.Change.Status)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1