Class GitService

java.lang.Object
edu.university.ecs.lab.common.services.GitService

public class GitService extends Object
Service for managing local repository including the cloning and resetting the current commit.
  • Constructor Details

    • GitService

      public GitService(String configPath)
    • GitService

      public GitService(Config config)
  • Method Details

    • cloneRemote

      public void cloneRemote()
      This method clones a remote repository to the local file system. Postcondition: the repository has been cloned to the local file system.
    • resetLocal

      public void resetLocal(String commitID)
      This method resets the local repository to commitID. Used to initially set commit for clone and additionally to advance the local repository as we step through commits
      Parameters:
      commitID - if empty or null, defaults to HEAD
    • resetLocal

      public boolean resetLocal(int relativeIndex)
      This method reset's the local branch to a relative commit from head
      Parameters:
      relativeIndex - if empty or null, defaults to HEAD
      Returns:
      boolean indicating success
    • initRepository

      public org.eclipse.jgit.lib.Repository initRepository()
      Establish a local endpoint for the given repository path.
      Returns:
      the repository object
    • getDifferences

      public List<org.eclipse.jgit.diff.DiffEntry> getDifferences(String commitOld, String commitNew) throws Exception
      Get the differences between commitOld and commitNew
      Parameters:
      commitOld - the old commit ID
      commitNew - the new commit ID
      Returns:
      the list of differences as DiffEntrys
      Throws:
      Exception
    • getLog

      public Iterable<org.eclipse.jgit.revwalk.RevCommit> getLog()