Exemplo n.º 1
0
  /** {@inheritDoc} */
  protected ScmResult executeAddCommand(
      ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary)
      throws ScmException {
    LocalScmProviderRepository localRepo = (LocalScmProviderRepository) repository;

    File[] files = fileSet.getFiles();
    List fileList = new ArrayList();
    for (int i = 0; i < files.length; i++) {
      String path = files[i].getPath().replace('\\', '/');
      localRepo.addFile(path);
      fileList.add(new ScmFile(path, ScmFileStatus.ADDED));
    }

    // TODO: Also, ensure it is tested from the update test
    return new AddScmResult(null, fileList);
  }
Exemplo n.º 2
0
  protected MkdirScmResult executeMkdirCommand(
      ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean createInLocal)
      throws ScmException {
    LocalScmProviderRepository repo = (LocalScmProviderRepository) repository;
    List<ScmFile> createdDirs = new ArrayList<ScmFile>();

    // create/commit the directory directly in the repository
    if (!createInLocal) {
      File file = (File) fileSet.getFileList().get(0);
      File modulePath = new File(repo.getRoot(), repo.getModule());
      File dir = new File(modulePath, file.getName());

      if (dir.exists()) {
        return new MkdirScmResult(
            null, "Directory already exists!", "Directory already exists.", false);
      } else {
        if (getLogger().isInfoEnabled()) {
          getLogger().info("Creating directory in '" + modulePath.getAbsolutePath() + "'");
        }

        FileUtils.mkdir(dir.getAbsolutePath());
        createdDirs.add(new ScmFile(dir.getPath(), ScmFileStatus.ADDED));
      }
    } else {
      // add the directory, but not commit
      LocalAddCommand addCmd = new LocalAddCommand();
      addCmd.setLogger(getLogger());

      CommandParameters parameters = new CommandParameters();
      parameters.setString(CommandParameter.MESSAGE, message);
      parameters.setString(CommandParameter.BINARY, "false");

      String path = ((File) fileSet.getFileList().get(0)).getPath();
      if (repo.isFileAdded(path)) {
        return new MkdirScmResult(
            null, "Directory already exists!", "Directory already exists.", false);
      }

      AddScmResult result = (AddScmResult) addCmd.execute(repository, fileSet, parameters);
      createdDirs.addAll(result.getAddedFiles());
    }

    return new MkdirScmResult(null, createdDirs);
  }