Пример #1
0
  @Override
  public PageData getRevisionData(FileSystemPage page, String label) {
    // Workaround for CachingPage
    if (label == null) {
      return persistence.getRevisionData(page, null);
    }
    String content, propertiesXml;
    RevCommit revCommit;
    Repository repository = getRepository(page);

    try {
      String fileSystemPath = getPath(page, repository);
      ObjectId rev = repository.resolve(label);
      RevWalk walk = new RevWalk(repository);
      revCommit = walk.parseCommit(rev);

      content = getRepositoryContent(repository, revCommit, fileSystemPath + "/" + contentFilename);
      propertiesXml =
          getRepositoryContent(repository, revCommit, fileSystemPath + "/" + propertiesFilename);
    } catch (IOException e) {
      throw new RuntimeException("Unable to get data for revision " + label, e);
    }

    final PageData pageData = new PageData(page);
    pageData.setContent(content);
    pageData.setProperties(
        parsePropertiesXml(propertiesXml, revCommit.getAuthorIdent().getWhen().getTime()));
    return pageData;
  }
Пример #2
0
 @Override
 public void deleteDirectory(File dir) {
   Repository repository = getRepository(dir);
   persistence.deleteDirectory(dir);
   Git git = new Git(repository);
   try {
     git.rm().addFilepattern(getPath(dir, repository)).call();
     commit(git, String.format("FitNesse directory %s deleted.", dir.getName()));
   } catch (GitAPIException e) {
     throw new RuntimeException(e);
   }
 }
Пример #3
0
 @Override
 public void addFile(File file, File contentFile) throws IOException {
   Repository repository = getRepository(file);
   persistence.addFile(file, contentFile);
   Git git = new Git(repository);
   try {
     git.add().addFilepattern(getPath(file, repository)).call();
     commit(git, String.format("FitNesse file %s updated.", file.getName()));
   } catch (GitAPIException e) {
     throw new RuntimeException(e);
   }
 }
Пример #4
0
 @Override
 public void renameFile(File file, File oldFile) {
   Repository repository = getRepository(file);
   persistence.renameFile(file, oldFile);
   Git git = new Git(repository);
   try {
     git.add().addFilepattern(getPath(file, repository)).call();
     git.rm().addFilepattern(getPath(oldFile, repository)).call();
     commit(
         git, String.format("FitNesse file %s moved to %s.", oldFile.getName(), file.getName()));
   } catch (GitAPIException e) {
     throw new RuntimeException(e);
   }
 }
Пример #5
0
 @Override
 public void delete(FileSystemPage page) {
   Repository repository = getRepository(page);
   Git git = new Git(repository);
   String fileSystemPath = getPath(page, repository);
   try {
     git.rm()
         .addFilepattern(fileSystemPath + "/" + contentFilename)
         .addFilepattern(fileSystemPath + "/" + propertiesFilename)
         .call();
     commit(
         git,
         String.format(
             "FitNesse page %s deleted.", PathParser.render(page.getPageCrawler().getFullPath())));
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
   persistence.delete(page);
 }
Пример #6
0
 @Override
 public VersionInfo makeVersion(FileSystemPage page, PageData data) {
   persistence.makeVersion(page, data);
   Repository repository = getRepository(page);
   Git git = new Git(repository);
   String fileSystemPath = getPath(page, repository);
   try {
     git.add()
         .addFilepattern(fileSystemPath + "/" + contentFilename)
         .addFilepattern(fileSystemPath + "/" + propertiesFilename)
         .call();
     commit(
         git,
         String.format(
             "FitNesse page %s updated.", PathParser.render(page.getPageCrawler().getFullPath())));
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
   return getCurrentVersion(repository);
 }
Пример #7
0
 @Override
 public void addDirectory(File dir) {
   persistence.addDirectory(dir);
 }