Ejemplo n.º 1
0
  @Test
  public void restorePageVersion() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);
    Page page = Page.fromText("old", "old"); // $NON-NLS-1$ //$NON-NLS-2$
    pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, null, USER);
    page = Page.fromText("new", "new"); // $NON-NLS-1$ //$NON-NLS-2$
    pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, null, USER);
    List<PageVersion> versions = pageStore.listPageVersions(PROJECT, BRANCH_1, PAGE);

    pageStore.restorePageVersion(PROJECT, BRANCH_1, PAGE, versions.get(1).getCommitName(), USER);
    Page result = pageStore.getPage(PROJECT, BRANCH_1, PAGE, true);
    assertEquals("old", ((PageTextData) result.getData()).getText()); // $NON-NLS-1$
    versions = pageStore.listPageVersions(PROJECT, BRANCH_1, PAGE);
    assertEquals(3, versions.size());

    assertClean(repo.r());
  }
Ejemplo n.º 2
0
  @Test
  public void listPageVersions() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);

    saveRandomPage(BRANCH_1, "home"); // $NON-NLS-1$
    RevCommit commit1 = CommitUtils.getLastCommit(repo.r(), "pages/home.page"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/foo"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home"); // $NON-NLS-1$
    RevCommit commit2 = CommitUtils.getLastCommit(repo.r(), "pages/home.page"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/bar"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home"); // $NON-NLS-1$
    RevCommit commit3 = CommitUtils.getLastCommit(repo.r(), "pages/home.page"); // $NON-NLS-1$
    saveRandomPage(BRANCH_1, "home/baz"); // $NON-NLS-1$

    List<PageVersion> versions =
        pageStore.listPageVersions(PROJECT, BRANCH_1, "home"); // $NON-NLS-1$
    assertEquals(3, versions.size());
    assertPageVersion(commit3, versions.get(0));
    assertPageVersion(commit2, versions.get(1));
    assertPageVersion(commit1, versions.get(2));
  }