Class GitUtils

java.lang.Object
edu.handong.csee.isel.bic.szz.util.GitUtils

public class GitUtils
extends java.lang.Object
The GitUtils class
collects of functions necessary to execute AG_SZZ
Author:
SJ, JY
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static org.eclipse.jgit.diff.DiffAlgorithm diffAlgorithm  
    static org.eclipse.jgit.diff.RawTextComparator diffComparator  
  • Constructor Summary

    Constructors 
    Constructor Description
    GitUtils()  
  • Method Summary

    Modifier and Type Method Description
    static RevsWithPath collectRevsWithSpecificPath​(java.util.List<PathRevision> pathRevisions, java.util.List<java.lang.String> targetPaths)
    Collect commit list related specific path
    static java.util.List<PathRevision> configurePathRevisionList​(org.eclipse.jgit.lib.Repository repo, java.util.List<org.eclipse.jgit.revwalk.RevCommit> commits)
    Get the path where change exists for all commit lists.
    static java.util.List<org.eclipse.jgit.diff.DiffEntry> diff​(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevTree parentTree, org.eclipse.jgit.revwalk.RevTree childTree)
    Conduct diff using diffAlgorithm that is MYERS Algorithm and diffComparator that is white space ignore all.
    static java.lang.String fetchBlob​(org.eclipse.jgit.lib.Repository repo, java.lang.String revSpec, java.lang.String path)  
    static java.lang.String fetchBlob​(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevCommit commit, java.lang.String path)
    get the file content using path info and commit info
    static java.util.ArrayList<org.eclipse.jgit.revwalk.RevCommit> getBFCList​(java.util.List<java.lang.String> issueKeys, java.util.List<org.eclipse.jgit.revwalk.RevCommit> revs)  
    static org.eclipse.jgit.diff.EditList getEditListFromDiff​(java.lang.String file1, java.lang.String file2)  
    static java.util.List<org.eclipse.jgit.revwalk.RevCommit> getRevs​(org.eclipse.jgit.api.Git git)  
    static java.util.List<java.lang.String> getTargetPaths​(org.eclipse.jgit.lib.Repository repo, java.util.List<org.eclipse.jgit.revwalk.RevCommit> BFCList)
    collect target path from bug fixing commit list.
    only java file path and file with change.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • diffAlgorithm

      public static org.eclipse.jgit.diff.DiffAlgorithm diffAlgorithm
    • diffComparator

      public static org.eclipse.jgit.diff.RawTextComparator diffComparator
  • Constructor Details

  • Method Details

    • getEditListFromDiff

      public static org.eclipse.jgit.diff.EditList getEditListFromDiff​(java.lang.String file1, java.lang.String file2)
    • diff

      public static java.util.List<org.eclipse.jgit.diff.DiffEntry> diff​(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevTree parentTree, org.eclipse.jgit.revwalk.RevTree childTree) throws java.io.IOException
      Conduct diff using diffAlgorithm that is MYERS Algorithm and diffComparator that is white space ignore all.
      Parameters:
      repo - Github repository
      parentTree - parent commit tree
      childTree - child commit tree
      Returns:
      diffs file path with change
      Throws:
      java.io.IOException - repository open faild
    • configurePathRevisionList

      public static java.util.List<PathRevision> configurePathRevisionList​(org.eclipse.jgit.lib.Repository repo, java.util.List<org.eclipse.jgit.revwalk.RevCommit> commits) throws java.io.IOException
      Get the path where change exists for all commit lists.
      Parameters:
      repo - Github repository
      commits - all commit list from input github project
      Returns:
      paths java file path with change
      Throws:
      java.io.IOException - IOException
    • collectRevsWithSpecificPath

      public static RevsWithPath collectRevsWithSpecificPath​(java.util.List<PathRevision> pathRevisions, java.util.List<java.lang.String> targetPaths)
      Collect commit list related specific path
      Parameters:
      pathRevisions - information commit and path
      targetPaths - target Paths
      Returns:
      revsWithPath revs With Path
    • fetchBlob

      public static java.lang.String fetchBlob​(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.revwalk.RevCommit commit, java.lang.String path) throws org.eclipse.jgit.errors.LargeObjectException, org.eclipse.jgit.errors.MissingObjectException, java.io.IOException
      get the file content using path info and commit info
      Parameters:
      repo - Github repository
      commit - commit
      path - target path
      Returns:
      string All file content
      Throws:
      org.eclipse.jgit.errors.LargeObjectException - LargeObjectException
      org.eclipse.jgit.errors.MissingObjectException - MissingObjectException
      java.io.IOException - IOException
    • fetchBlob

      public static java.lang.String fetchBlob​(org.eclipse.jgit.lib.Repository repo, java.lang.String revSpec, java.lang.String path) throws org.eclipse.jgit.errors.RevisionSyntaxException, org.eclipse.jgit.errors.AmbiguousObjectException, org.eclipse.jgit.errors.IncorrectObjectTypeException, java.io.IOException
      Throws:
      org.eclipse.jgit.errors.RevisionSyntaxException
      org.eclipse.jgit.errors.AmbiguousObjectException
      org.eclipse.jgit.errors.IncorrectObjectTypeException
      java.io.IOException
    • getRevs

      public static java.util.List<org.eclipse.jgit.revwalk.RevCommit> getRevs​(org.eclipse.jgit.api.Git git) throws org.eclipse.jgit.api.errors.NoHeadException, org.eclipse.jgit.api.errors.GitAPIException
      Throws:
      org.eclipse.jgit.api.errors.NoHeadException
      org.eclipse.jgit.api.errors.GitAPIException
    • getBFCList

      public static java.util.ArrayList<org.eclipse.jgit.revwalk.RevCommit> getBFCList​(java.util.List<java.lang.String> issueKeys, java.util.List<org.eclipse.jgit.revwalk.RevCommit> revs)
    • getTargetPaths

      public static java.util.List<java.lang.String> getTargetPaths​(org.eclipse.jgit.lib.Repository repo, java.util.List<org.eclipse.jgit.revwalk.RevCommit> BFCList) throws java.io.IOException
      collect target path from bug fixing commit list.
      only java file path and file with change.
      Parameters:
      repo - Github repository
      BFCList - bug fixing list
      Returns:
      targetPaths path from bfc list
      Throws:
      java.io.IOException - IOException