コード例 #1
0
  @Test
  public void canCommitFileInProject() throws Exception {
    String fileName = "a.txt";
    String fileContent = "*****@*****.**";

    IFile file = testUtils.addFileToProject(testProject.getProject(), fileName, fileContent);
    testRepository.add(file);

    EGitUtils.commit(testProject.getProject(), null);

    testUtils.assertRepositoryContainsFilesWithContent(
        testRepository.getRepository(),
        new String[] {testUtils.getPathInRepository(file), fileContent});
  }
コード例 #2
0
 private TestRepository createTestRepository(TestProject project) throws IOException, Exception {
   TestRepository testRepository = new TestRepository(TestUtils.createGitDir(project));
   testRepository.createMockSystemReader(ResourcesPlugin.getWorkspace().getRoot().getLocation());
   testRepository.setUserAndEmail(GIT_USER, GIT_EMAIL);
   testRepository.connect(project.getProject());
   testRepository.add(project.getFile(".project"));
   testRepository.initialCommit();
   return testRepository;
 }
コード例 #3
0
  @Test
  public void forcedPushRemovesFileInRemote() throws Exception {
    String fileName = "a.txt";
    String fileContent = "*****@*****.**";
    File file = testRepository.createFile(fileName, fileContent);
    testRepository.addAndCommit(file, "adding a file");

    File file2 = testRepository2.createFile("b.txt", "bingobongo");
    testRepository2.addAndCommit(file2, "adding a file");

    testRepository.addRemoteTo(REPO2_REMOTE_NAME, testRepository2.getRepository());
    EGitUtils.pushForce(REPO2_REMOTE_NAME, testRepository.getRepository(), null);

    // repo2 mustn't contain "b.txt"
    testUtils.assertRepositoryMisses(testRepository2.getRepository(), file2.getName());
    // repo2 must contain "a.txt"
    testUtils.assertRepositoryContainsFilesWithContent(
        testRepository2.getRepository(), fileName, fileContent);
  }
コード例 #4
0
  @Test
  public void fileAddedToCloneIsInRemoteAfterPush() throws Exception {
    String fileName = "c.txt";
    String fileContent = "*****@*****.**";
    File file = testRepositoryClone.createFile(fileName, fileContent);
    testRepositoryClone.addAndCommit(file, "adding a file");

    testRepositoryClone.addRemoteTo(REPO2_REMOTE_NAME, testRepository2.getRepository());
    EGitUtils.pushForce(REPO2_REMOTE_NAME, testRepositoryClone.getRepository(), null);

    // repo2 must contain file added to clone
    testUtils.assertRepositoryContainsFilesWithContent(
        testRepository2.getRepository(), fileName, fileContent);
  }
コード例 #5
0
  @Test
  public void fileAddedToCloneIsInOriginAfterPush() throws Exception {
    String fileName = "b.txt";
    String fileContent = "*****@*****.**";

    File file = testRepositoryClone.createFile(fileName, fileContent);
    testRepositoryClone.addAndCommit(file, "adding a file");

    EGitUtils.push(testRepositoryClone.getRepository(), null);

    // does origin contain file added to clone?
    testUtils.assertRepositoryContainsFilesWithContent(
        testRepository.getRepository(), fileName, fileContent);
  }