コード例 #1
0
  @Override
  @After
  public void tearDown() throws Exception {

    repositoryUtil.dispose();

    if (workdir.exists()) FileUtils.delete(workdir, FileUtils.RECURSIVE | FileUtils.RETRY);
    super.tearDown();
  }
コード例 #2
0
  @Override
  @After
  public void tearDown() throws Exception {
    if (repository1 != null) repository1.close();
    if (repository2 != null) repository2.close();
    if (repository3 != null) repository3.close();

    if (workdir.exists()) FileUtils.delete(workdir, FileUtils.RECURSIVE | FileUtils.RETRY);
    if (workdir2.exists()) FileUtils.delete(workdir2, FileUtils.RECURSIVE | FileUtils.RETRY);
    if (workdir3.exists()) FileUtils.delete(workdir3, FileUtils.RECURSIVE | FileUtils.RETRY);
    super.tearDown();
  }
コード例 #3
0
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();
    workdir = new File("D://Repository1");

    if (workdir.exists()) {
      FileUtils.delete(workdir, FileUtils.RECURSIVE | FileUtils.RETRY);
    }
    FileUtils.mkdir(workdir, true);

    repositoryUtil = new RepositoryUtil(new File(workdir, Constants.DOT_GIT));

    repository = repositoryUtil.getRepository();
  }
コード例 #4
0
  @Override
  @Before
  public void setUp() throws Exception {
    super.setUp();

    // create Main Git Repository
    workdir = new File("D://Repository1");

    if (workdir.exists()) {
      FileUtils.delete(workdir, FileUtils.RECURSIVE | FileUtils.RETRY);
    }
    FileUtils.mkdir(workdir, true);

    // init RepositoryUtil class
    repositoryUtil = new RepositoryUtil(new File(workdir, Constants.DOT_GIT));

    repository1 = repositoryUtil.getRepository();

    // create file, add and commit
    File file = new File(workdir, "file.txt");
    FileUtils.createNewFile(file);
    repositoryUtil.appendFileContent(file, "Contect file");
    Git git = new Git(repository1);
    git.add().addFilepattern("file.txt").call();
    git.commit().setMessage("First Commit").call();

    // clone Git Repository 2
    workdir2 = new File("D:/Repository2");

    if (workdir2.exists()) {
      FileUtils.delete(workdir2, FileUtils.RECURSIVE | FileUtils.RETRY);
    }
    FileUtils.mkdir(workdir2, true);

    URIish uri = new URIish("file:///" + repository1.getDirectory().toString());

    CloneOperation clop =
        new CloneOperation(
            uri.toString(), true, null, workdir2, "refs/heads/master", "origin", 0, null, null);
    clop.execute();

    repository2 = new FileRepository(new File(workdir2, Constants.DOT_GIT));

    // clone Git Repository 3
    workdir3 = new File("D:/Repository3");

    if (workdir3.exists()) {
      FileUtils.delete(workdir3, FileUtils.RECURSIVE | FileUtils.RETRY);
    }
    FileUtils.mkdir(workdir3, true);

    uri = new URIish("file:///" + repository1.getDirectory().toString());

    clop =
        new CloneOperation(
            uri.toString(), true, null, workdir3, "refs/heads/master", "origin", 0, null, null);
    clop.execute();

    repository3 = new FileRepository(new File(workdir3, Constants.DOT_GIT));

    RefUpdate createBranch = repository2.updateRef("refs/heads/test");
    createBranch.setNewObjectId(repository2.resolve("refs/heads/master"));
    createBranch.update();
  }