Example #1
0
  @Test
  public void savePageWithSameBaseCommitAndConflictingChanges()
      throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    ILockedRepository repo =
        globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
    register(repo);
    Page page =
        Page.fromText("title", "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$
    pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, null, USER);
    String baseCommit = pageStore.getPageMetadata(PROJECT, BRANCH_1, PAGE).getCommit();

    page = Page.fromText("title", "a\nbbb\nc\nd\ne\nf\ng\nh\ni\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$
    pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, baseCommit, USER);
    page = Page.fromText("title", "a\nxxx\nc\nd\ne\nf\ng\nh\ni\nj\n"); // $NON-NLS-1$ //$NON-NLS-2$
    MergeConflict conflict = pageStore.savePage(PROJECT, BRANCH_1, PAGE, page, baseCommit, USER);

    Page result = pageStore.getPage(PROJECT, BRANCH_1, PAGE, true);
    assertNotNull(conflict);
    assertEquals(
        "a\nbbb\nc\nd\ne\nf\ng\nh\ni\nj\n",
        ((PageTextData) result.getData()).getText()); // $NON-NLS-1$
    assertEquals(
        "a\n<<<<<<< OURS\nbbb\n=======\nxxx\n>>>>>>> THEIRS\nc\nd\ne\nf\ng\nh\ni\nj\n",
        conflict.getText()); // $NON-NLS-1$

    assertClean(repo.r());
  }
Example #2
0
  @Test
  public void getPageForCommit() throws IOException, GitAPIException {
    register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
    register(globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null));
    Page oldPage = saveRandomPage(BRANCH_1, "home"); // $NON-NLS-1$
    String oldCommit =
        pageStore.getPageMetadata(PROJECT, BRANCH_1, "home").getCommit(); // $NON-NLS-1$
    Page newPage = saveRandomPage(BRANCH_1, "home"); // $NON-NLS-1$
    String newCommit =
        pageStore.getPageMetadata(PROJECT, BRANCH_1, "home").getCommit(); // $NON-NLS-1$
    assertFalse(oldPage.getData().equals(newPage.getData()));
    assertFalse(newCommit.equals(oldCommit));

    Page result = pageStore.getPage(PROJECT, BRANCH_1, "home", oldCommit, true); // $NON-NLS-1$
    assertEquals(oldPage.getData(), result.getData());
    result = pageStore.getPage(PROJECT, BRANCH_1, "home", newCommit, true); // $NON-NLS-1$
    assertEquals(newPage.getData(), result.getData());
  }
Example #3
0
 @Test
 public void getPageMetadata() throws IOException, GitAPIException {
   register(globalRepoManager.createProjectCentralRepository(PROJECT, USER));
   ILockedRepository repo =
       globalRepoManager.createProjectBranchRepository(PROJECT, BRANCH_1, null);
   register(repo);
   saveRandomPage(BRANCH_1, PAGE);
   File file =
       new File(
           new File(RepositoryUtil.getWorkingDir(repo.r()), "pages"),
           PAGE + ".page"); // $NON-NLS-1$ //$NON-NLS-2$
   long size = file.length();
   PageMetadata metadata = pageStore.getPageMetadata(PROJECT, BRANCH_1, PAGE);
   assertEquals(USER.getLoginName(), metadata.getLastEditedBy());
   assertSecondsAgo(metadata.getLastEdited(), 5);
   assertEquals(size, metadata.getSize());
 }