Example #1
0
  @Override
  public void getChanges(
      VcsDirtyScope dirtyScope, ChangelistBuilder builder, ProgressIndicator progress)
      throws VcsException {
    Collection<VirtualFile> roots = dirtyScope.getAffectedContentRoots();
    ChangeMonitor mon = ChangeMonitor.getInstance(project);
    FileTypeManager ftm = FileTypeManager.getInstance();
    for (VirtualFile root : roots) {
      GitCommand command = new GitCommand(project, settings, root);

      // process Git cached/indexed files
      Set<GitVirtualFile> files = command.gitCachedFiles();
      for (GitVirtualFile file : files) {
        if (ftm.isFileIgnored(file.getPath())) { // IDEA (not Git) is configured to ignore this file
          builder.processIgnoredFile(file);
          continue;
        }
        Change c = getChange(file);
        if (c != null) builder.processChange(c);
      }
      // process Git uncached modified files
      Set<String> unCachedFilenames = mon.getUncachedFiles(root);
      if (unCachedFilenames != null && unCachedFilenames.size() > 0) {
        for (String filename : unCachedFilenames) {
          if (filename == null || ftm.isFileIgnored(filename)) continue;
          GitVirtualFile file =
              new GitVirtualFile(project, filename, GitVirtualFile.Status.MODIFIED);
          Change c = getChange(file);
          if (c != null) builder.processChange(c);
        }
      }
      // process Git unversioned files
      Set<String> otherFilenames = mon.getOtherFiles(root);
      if (otherFilenames != null && otherFilenames.size() > 0) {
        for (String filename : otherFilenames) {
          if (filename == null) continue;
          if (ftm.isFileIgnored(filename)) // IDEA (not Git) is configured to ignore this file
          builder.processIgnoredFile(
                new GitVirtualFile(project, filename, GitVirtualFile.Status.IGNORED));
          else
            builder.processUnversionedFile(
                new GitVirtualFile(project, filename, GitVirtualFile.Status.UNVERSIONED));
        }
      }
      // process Git configured ignored files
      //            Set<String> ignoredFilenames = mon.getIgnoredFiles(root);
      //            if (ignoredFilenames != null && ignoredFilenames.size() > 0) {
      //                for (String filename : ignoredFilenames) {
      //                    if (filename == null) continue;
      //                        builder.processIgnoredFile(
      //                                new GitVirtualFile(project, filename,
      // GitVirtualFile.Status.IGNORED));
      //                }
      //            }
    }
  }
 @Override
 public void getChanges(
     VcsDirtyScope dirtyScope,
     final ChangelistBuilder builder,
     ProgressIndicator progress,
     ChangeListManagerGate addGate)
     throws VcsException {
   for (FilePath path : dirtyScope.getDirtyFiles()) {
     builder.processUnversionedFile(path.getVirtualFile());
   }
   final Processor<VirtualFile> processor =
       new Processor<VirtualFile>() {
         @Override
         public boolean process(final VirtualFile vf) {
           builder.processUnversionedFile(vf);
           return true;
         }
       };
   for (FilePath dir : dirtyScope.getRecursivelyDirtyDirectories()) {
     VfsUtil.processFilesRecursively(dir.getVirtualFile(), processor);
   }
 }