Examples of BlameResult


Examples of org.eclipse.jgit.blame.BlameResult

    config.save();
    git.reset().setMode(ResetType.HARD).call();

    BlameCommand command = new BlameCommand(db);
    command.setFilePath("file.txt");
    BlameResult lines = command.call();

    assertEquals(3, lines.getResultContents().size());
    assertEquals(commit, lines.getSourceCommit(0));
    assertEquals(commit, lines.getSourceCommit(1));
    assertEquals(commit, lines.getSourceCommit(2));
  }
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

    RevCommit merge = commitFile("file.txt",
        join("0", "1 side", "2", "3 resolved", "4"), "master");

    BlameCommand command = new BlameCommand(db);
    command.setFilePath("file.txt");
    BlameResult lines = command.call();

    assertEquals(5, lines.getResultContents().size());
    assertEquals(base, lines.getSourceCommit(0));
    assertEquals(side, lines.getSourceCommit(1));
    assertEquals(base, lines.getSourceCommit(2));
    assertEquals(merge, lines.getSourceCommit(3));
    assertEquals(base, lines.getSourceCommit(4));
  }
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

    RevCommit merge = commitFile("file.txt",
        join("0", "1 side", "2", "3 resolved", "4"), "master");

    BlameCommand command = new BlameCommand(db);
    command.setFilePath("file.txt");
    BlameResult lines = command.call();

    assertEquals(5, lines.getResultContents().size());
    assertEquals(base, lines.getSourceCommit(0));
    assertEquals(side, lines.getSourceCommit(1));
    assertEquals(base, lines.getSourceCommit(2));
    assertEquals(merge, lines.getSourceCommit(3));
    assertEquals(base, lines.getSourceCommit(4));
  }
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

    BlameCommand command = new BlameCommand(db);
    command.setFilePath("file.txt")
        .setTextComparator(RawTextComparator.WS_IGNORE_ALL)
        .setStartCommit(merge.getId());
    BlameResult lines = command.call();

    assertEquals(3, lines.getResultContents().size());
    assertEquals(base, lines.getSourceCommit(0));
    assertEquals(base, lines.getSourceCommit(1));
    assertEquals(side, lines.getSourceCommit(2));
  }
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

    // and test again with other BlameGenerator API:
    generator = new BlameGenerator(db, FILENAME_2);
    try {
      generator.push(null, db.resolve(Constants.HEAD));
      BlameResult result = generator.computeBlameResult();

      assertEquals(3, result.getResultContents().size());

      assertEquals(c2, result.getSourceCommit(0));
      assertEquals(FILENAME_2, result.getSourcePath(0));

      assertEquals(c1, result.getSourceCommit(1));
      assertEquals(FILENAME_1, result.getSourcePath(1));

      assertEquals(c1, result.getSourceCommit(2));
      assertEquals(FILENAME_1, result.getSourcePath(2));

    } finally {
      generator.release();
    }
  }
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

      blameCommand.setTextComparator(RawTextComparator.WS_IGNORE_ALL);

      if (blame.getStartCommit() != null) {
        blameCommand.setStartCommit(blame.getStartCommit());
      }
      BlameResult result;

      try {
        result = blameCommand.call();
      } catch (Exception e1) {
        return;
      }
      if (result != null) {
        blame.clearLines();
        RevCommit commit;
        RevCommit prevCommit = null;
        String path;
        String prevPath = null;
        for (int i = 0; i < result.getResultContents().size(); i++) {
          try {
            commit = result.getSourceCommit(i);
            prevCommit = commit;
          } catch (NullPointerException e) {
            commit = prevCommit;
          }
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

        Git git = null;
        File basedir = workingDirectory.getBasedir();
        try
        {
            git = Git.open( basedir );
            BlameResult blameResult = git.blame().setFilePath( filename ).call();

            List<BlameLine> lines = new ArrayList<BlameLine>();

            int i = 0;
            while ( ( i = blameResult.computeNext() ) != -1 )
            {
                lines.add( new BlameLine( blameResult.getSourceAuthor( i ).getWhen(),
                                          blameResult.getSourceCommit( i ).getName(),
                                          blameResult.getSourceAuthor( i ).getName(),
                                          blameResult.getSourceCommitter( i ).getName() ) );
            }

            return new BlameScmResult( "JGit blame", lines );
        }
        catch ( Exception e )
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

            RevCommit start) throws GitAPIException, IOException {
        DiffFormatter diffFormatter = new DiffFormatter(NullOutputStream.INSTANCE);
        try {
            diffFormatter.setRepository(repository);
            EditList edits = diffFormatter.toFileHeader(diff).toEditList();
            BlameResult blameResult = new Git(repository).blame()
                    .setFilePath(diff.getOldPath())
                    .setFollowFileRenames(true)
                    .setStartCommit(start).call();
            return getAuthorsFromBlameResult(edits, blameResult);
        } finally {
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

    }
    if (Activator.getDefault().getPreferenceStore()
        .getBoolean(UIPreferences.BLAME_IGNORE_WHITESPACE))
      command.setTextComparator(RawTextComparator.WS_IGNORE_ALL);

    BlameResult result;
    try {
      result = command.call();
    } catch (Exception e1) {
      Activator.error(e1.getMessage(), e1);
      return;
    }
    if (result == null)
      return;

    Map<RevCommit, BlameRevision> revisions = new HashMap<RevCommit, BlameRevision>();
    int lineCount = result.getResultContents().size();
    BlameRevision previous = null;
    for (int i = 0; i < lineCount; i++) {
      RevCommit commit = result.getSourceCommit(i);
      String sourcePath = result.getSourcePath(i);
      if (commit == null) {
        // Unregister the current revision
        if (previous != null) {
          previous.register();
          previous = null;
        }
        continue;
      }
      BlameRevision revision = revisions.get(commit);
      if (revision == null) {
        revision = new BlameRevision();
        revision.setRepository(repository);
        revision.setCommit(commit);
        revision.setSourcePath(sourcePath);
        revisions.put(commit, revision);
        info.addRevision(revision);
      }
      revision.addSourceLine(i, result.getSourceLine(i));
      if (previous != null)
        if (previous == revision)
          previous.addLine();
        else {
          previous.register();
View Full Code Here

Examples of org.eclipse.jgit.blame.BlameResult

        BlameCommand blamer = new BlameCommand(repository);
        ObjectId commitID = repository.resolve("HEAD");
        blamer.setStartCommit(commitID);
        blamer.setFilePath("README.md");
        BlameResult blame = blamer.call();

        // read the number of lines from the commit to not look at changes in the working copy
        int lines = countFiles(repository, commitID, "README.md");
        for (int i = 0; i < lines; i++) {
            RevCommit commit = blame.getSourceCommit(i);
            System.out.println("Line: " + i + ": " + commit);
        }

        System.out.println("Displayed commits responsible for " + lines + " lines of README.md");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.