Beispiel #1
0
  /**
   * The old File methods traverse symbolic links and look at the targets. With symbolic links we
   * usually want to modify/look at the link. For some reason the executable attribute seems to
   * always look at the target, but for the other attributes like lastModified, hidden and exists we
   * must differ between the link and the target.
   *
   * @throws IOException
   * @throws InterruptedException
   */
  @Test
  public void testSymlinkAttributes() throws IOException, InterruptedException {
    FS fs = FS.DETECTED;
    File link = new File(trash, "x");
    File target = new File(trash, "y");
    fs.createSymLink(link, "y");
    assertTrue(fs.exists(link));
    String targetName = fs.readSymLink(link);
    assertEquals("y", targetName);
    assertTrue(fs.lastModified(link) > 0);
    assertTrue(fs.exists(link));
    assertFalse(fs.canExecute(link));
    assertEquals(1, fs.length(link));
    assertFalse(fs.exists(target));
    assertFalse(fs.isFile(target));
    assertFalse(fs.isDirectory(target));
    assertFalse(fs.canExecute(target));

    RepositoryTestCase.fsTick(link);
    // Now create the link target
    FileUtils.createNewFile(target);
    assertTrue(fs.exists(link));
    assertTrue(fs.lastModified(link) > 0);
    assertTrue(fs.lastModified(target) > fs.lastModified(link));
    assertFalse(fs.canExecute(link));
    fs.setExecute(target, true);
    assertFalse(fs.canExecute(link));
    assertTrue(fs.canExecute(target));
  }
Beispiel #2
0
  @Before
  public void setUp() throws Exception {
    super.setUp();
    git = new Git(db);

    // create test files
    writeTrashFile("File1.txt", "Hello world");
    writeTrashFile("File2.txt", "Delete Me");
    writeTrashFile("File3.txt", "Delete Me");

    // create files in sub-directories.
    writeTrashFile("sub-noclean/File1.txt", "Hello world");
    writeTrashFile("sub-noclean/File2.txt", "Delete Me");
    writeTrashFile("sub-clean/File4.txt", "Delete Me");
    writeTrashFile("sub-noclean/Ignored.txt", "Ignored");
    writeTrashFile(".gitignore", "/ignored-dir\n/sub-noclean/Ignored.txt");
    writeTrashFile("ignored-dir/Ignored2.txt", "Ignored");

    // add and commit first file
    git.add().addFilepattern("File1.txt").call();
    git.add().addFilepattern("sub-noclean/File1.txt").call();
    git.add().addFilepattern(".gitignore").call();
    git.commit().setMessage("Initial commit").call();
  }
Beispiel #3
0
 protected static void fsTick() throws InterruptedException, IOException {
   RepositoryTestCase.fsTick(null);
 }
 @Override
 @Before
 public void setUp() throws Exception {
   super.setUp();
   git = new Git(db);
 }