Class GitService
java.lang.Object
edu.university.ecs.lab.common.services.GitService
Service for managing local repository including the cloning
and resetting the current commit.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method clones a remote repository to the local file system.List<org.eclipse.jgit.diff.DiffEntry>
getDifferences
(String commitOld, String commitNew) Get the differences between commitOld and commitNewIterable<org.eclipse.jgit.revwalk.RevCommit>
getLog()
org.eclipse.jgit.lib.Repository
Establish a local endpoint for the given repository path.boolean
resetLocal
(int relativeIndex) This method reset's the local branch to a relative commit from headvoid
resetLocal
(String commitID) This method resets the local repository to commitID.
-
Constructor Details
-
GitService
-
GitService
-
-
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
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 IDcommitNew
- the new commit ID- Returns:
- the list of differences as DiffEntrys
- Throws:
Exception
-
getLog
-