Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.IndexDiff


   */
  public Status call() throws IOException, NoWorkTreeException {
    if (workingTreeIt == null)
      workingTreeIt = new FileTreeIterator(repo);

    IndexDiff diff = new IndexDiff(repo, Constants.HEAD, workingTreeIt);
    diff.diff();

    return new Status(diff);
  }
View Full Code Here


   */
  public Status call() throws IOException, NoWorkTreeException {
    if (workingTreeIt == null)
      workingTreeIt = new FileTreeIterator(repo);

    IndexDiff diff = new IndexDiff(repo, Constants.HEAD, workingTreeIt);
    diff.diff();

    return new Status(diff);
  }
View Full Code Here

  public Status call() throws GitAPIException, NoWorkTreeException {
    if (workingTreeIt == null)
      workingTreeIt = new FileTreeIterator(repo);

    try {
      IndexDiff diff = new IndexDiff(repo, Constants.HEAD, workingTreeIt);
      if (ignoreSubmoduleMode != null)
        diff.setIgnoreSubmoduleMode(ignoreSubmoduleMode);
      if (paths != null)
        diff.setFilter(PathFilterGroup.createFromStrings(paths));
      if (progressMonitor == null)
        diff.diff();
      else
        diff.diff(progressMonitor, ProgressMonitor.UNKNOWN,
            ProgressMonitor.UNKNOWN, ""); //$NON-NLS-1$
      return new Status(diff);
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }
View Full Code Here

        public Status(ObjectId id, FileRepository repository) throws IOException {
            sha1 = id;
            this.repository = repository;

            FileTreeIterator workingTreeIt = new FileTreeIterator(repository);
            index = new IndexDiff(repository, Constants.HEAD, workingTreeIt);
            index.diff();
        }
View Full Code Here

        verify(indexDiff).diff();
    }

    @Test
    public void testIsDirtyIgnoreUntracked() throws Exception {
        IndexDiff indexDiff = this.mockIndexDiff();
        HashSet<String> added = new HashSet<String>();
        added.add("somefile");
        when(indexDiff.getAdded()).thenReturn(added);

        assertThat(this.repository.isDirty(true), is(true));

        verify(indexDiff).diff();
    }
View Full Code Here

    protected IndexDiff mockIndexDiff() throws Exception {
        FileTreeIterator fileTreeIterator = mock(FileTreeIterator.class);
        whenNew(FileTreeIterator.class).
            withArguments(this.repo).thenReturn(fileTreeIterator);

        IndexDiff indexDiff = mock(IndexDiff.class);
        whenNew(IndexDiff.class).
            withParameterTypes(Repository.class, ObjectId.class, WorkingTreeIterator.class).
            withArguments(eq(this.repo), any(ObjectId.class), eq(fileTreeIterator)).
            thenReturn(indexDiff);
View Full Code Here

    }

    public boolean isDirty(boolean ignoreUntracked) throws GitRepositoryException {
        try {
            FileTreeIterator workTreeIterator = new FileTreeIterator(this.repository);
            IndexDiff indexDiff = new IndexDiff(this.repository, this.getHeadObject(), workTreeIterator);
            indexDiff.diff();

            return !ignoreUntracked && !indexDiff.getUntracked().isEmpty() ||
                    !(indexDiff.getAdded().isEmpty() && indexDiff.getChanged().isEmpty() &&
                    indexDiff.getRemoved().isEmpty() &&
                    indexDiff.getMissing().isEmpty() &&
                    indexDiff.getModified().isEmpty() &&
                    indexDiff.getConflicting().isEmpty());

        } catch (IOException e) {
            throw new GitRepositoryException("Could not create repository diff.", e);
        }
    }
View Full Code Here

        this.repository.check();
    }

    @Test
    public void testClean() throws Exception {
        IndexDiff indexDiff = this.mockIndexDiff();
        when(indexDiff.getAdded()).thenReturn(Collections.<String> emptySet());
        when(indexDiff.getChanged()).thenReturn(Collections.<String>emptySet());
        when(indexDiff.getRemoved()).thenReturn(Collections.<String>emptySet());
        when(indexDiff.getMissing()).thenReturn(Collections.<String> emptySet());
        when(indexDiff.getModified()).thenReturn(Collections.<String>emptySet());
        when(indexDiff.getConflicting()).thenReturn(Collections.<String>emptySet());
        when(indexDiff.getUntracked()).thenReturn(Collections.<String>emptySet());

        assertThat(this.repository.isDirty(false), is(false));

        verify(indexDiff).diff();
    }
View Full Code Here

        verify(indexDiff).diff();
    }

    @Test
    public void testCleanIgnoreUntracked() throws Exception {
        IndexDiff indexDiff = this.mockIndexDiff();
        when(indexDiff.getAdded()).thenReturn(Collections.<String> emptySet());
        when(indexDiff.getChanged()).thenReturn(Collections.<String> emptySet());
        when(indexDiff.getRemoved()).thenReturn(Collections.<String> emptySet());
        when(indexDiff.getMissing()).thenReturn(Collections.<String> emptySet());
        when(indexDiff.getModified()).thenReturn(Collections.<String> emptySet());
        when(indexDiff.getConflicting()).thenReturn(Collections.<String> emptySet());

        assertThat(this.repository.isDirty(true), is(false));

        verify(indexDiff).diff();
    }
View Full Code Here

        assertThat(repo.getTags(), is(equalTo(tags)));
    }

    @Test
    public void testIsDirty() throws Exception {
        IndexDiff indexDiff = this.mockIndexDiff();
        HashSet<String> untracked = new HashSet<String>();
        untracked.add("somefile");
        when(indexDiff.getUntracked()).thenReturn(untracked);

        assertThat(this.repository.isDirty(false), is(true));

        verify(indexDiff).diff();
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.IndexDiff

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.