Java 类org.eclipse.jgit.api.RmCommand 实例源码

项目:che    文件:JGitConnection.java   
/** To add deleted files in index it is required to perform git rm on them */
private void addDeletedFilesToIndexIfNeeded(List<String> filePatterns) throws GitAPIException {
  Set<String> deletedFiles = getGit().status().call().getMissing();
  if (deletedFiles.isEmpty()) {
    return;
  }
  if (!filePatterns.isEmpty() && !filePatterns.contains(".")) {
    deletedFiles =
        deletedFiles.stream().filter(filePatterns::contains).collect(Collectors.toSet());
  }
  if (!deletedFiles.isEmpty()) {
    RmCommand rmCommand = getGit().rm();
    deletedFiles.forEach(rmCommand::addFilepattern);
    rmCommand.call();
  }
}
项目:che    文件:JGitConnection.java   
@Override
public void rm(RmParams params) throws GitException {
  List<String> files = params.getItems();
  RmCommand rmCommand = getGit().rm();

  rmCommand.setCached(params.isCached());

  if (files != null) {
    files.forEach(rmCommand::addFilepattern);
  }
  try {
    rmCommand.call();
  } catch (GitAPIException exception) {
    throw new GitException(exception.getMessage(), exception);
  }
}
项目:fitnesse-git-plugin    文件:GitFileVersionsController.java   
@Override
public void delete(File... files) throws IOException {
  Repository repository = getRepository(files[0]);
  Git git = new Git(repository);
  try {
    RmCommand remover = git.rm();
    for (File file : files) {
      remover.addFilepattern(getPath(file, repository));
    }
    remover.call();
    commit(git, String.format("[FitNesse] Deleted files: %s.", formatFiles(files)), null);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
  persistence.delete(files);
}
项目:oxygen-git-plugin    文件:GitAccess.java   
/**
 * Adds multiple files to the staging area. Preparing the for commit
 * 
 * @param fileNames
 *          - the names of the files to be added
 */
public void addAll(List<FileStatus> files) {

    try {

      RmCommand removeCmd = null;
      AddCommand addCmd = null;

        for (FileStatus file : files) {
            if (file.getChangeType() == GitChangeType.MISSING) {
              if (removeCmd == null) {
                removeCmd = git.rm();
              }
         removeCmd.addFilepattern(file.getFileLocation());
            } else {
              if (addCmd == null) {
                addCmd = git.add();
              }
         addCmd.addFilepattern(file.getFileLocation());
            }
        }

        if (removeCmd != null) {
          removeCmd.call();
        }

        if (addCmd != null) {
          addCmd.call();
        }

        fireFileStateChanged(new ChangeEvent(GitCommand.STAGE, getPaths(files)));
    } catch (GitAPIException e) {
        if (logger.isDebugEnabled()) {
            logger.debug(e, e);
        }
    }
}
项目:ghp-maven-plugin    文件:GitHubPages.java   
private void clearDirectory(File dir) throws MojoExecutionException {
    RmCommand rm = git.rm();
    if (forEachPath(dir, rm::addFilepattern)) {
        try {
            rm.call();
        } catch (GitAPIException e) {
            throw new MojoExecutionException("Could not remove files from directory and git", e);
        }
    }
}
项目:ISAAC    文件:SyncServiceGIT.java   
/**
 * @see gov.va.isaac.interfaces.sync.ProfileSyncI#removeFiles(java.io.File, java.util.Set)
 */
@Override
public void removeFiles(String... files) throws IllegalArgumentException, IOException
{
    try
    {
        log.info("Remove Files called {}", Arrays.toString(files));
        Git git = getGit();
        if (files.length == 0)
        {
            log.debug("No files to remove");
        }
        else
        {
            RmCommand rm = git.rm();
            for (String file : files)
            {
                rm.addFilepattern(file);
            }
            rm.call();
        }
        log.info("removeFiles Complete.  Current status: " + statusToString(git.status().call()));
    }
    catch (GitAPIException e)
    {
        log.error("Unexpected", e);
        throw new IOException("Internal error", e);
    }
}