Klasse JGitRepository

java.lang.Object
com.github.koraktor.mavanagaiata.git.AbstractGitRepository
com.github.koraktor.mavanagaiata.git.jgit.JGitRepository
Alle implementierten Schnittstellen:
GitRepository, AutoCloseable

public class JGitRepository extends AbstractGitRepository
Wrapper around JGit's Repository object to represent a Git repository
Autor:
Sebastian Staudt
  • Felddetails

  • Konstruktordetails

    • JGitRepository

      JGitRepository()
      Creates a new empty instance
    • JGitRepository

      public JGitRepository(File workTree, File gitDir, String headRef) throws GitRepositoryException
      Creates a new instance for the given worktree and or Git directory
      Parameter:
      workTree - The worktree of the repository or null
      gitDir - The GIT_DIR of the repository or null
      headRef - The ref to use as HEAD
      Löst aus:
      GitRepositoryException - if the parameters do not match a Git repository
  • Methodendetails

    • buildRepository

      final void buildRepository(File workTree, File gitDir) throws GitRepositoryException
      Löst aus:
      GitRepositoryException
    • check

      public void check() throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Checks whether the Git repository is accessible.
      Löst aus:
      GitRepositoryException - if the repository is not accessible.
    • close

      public void close()
      Closes any resources that are needed to access this repository

      Closes JGit's repository instance.

      Siehe auch:
    • describe

      public GitTagDescription describe() throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Describes the current Git commit like git describe does
      Gibt zurück:
      The description of the current HEAD commit
      Löst aus:
      GitRepositoryException - if the description cannot be created
    • getHeadRef

      public String getHeadRef()
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns the Git ref used as the HEAD commit of the repository
      Gibt zurück:
      The ref used as HEAD
    • getAbbreviatedCommitId

      public String getAbbreviatedCommitId(GitCommit commit) throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns the abbreviated commit SHA ID of the given Git commit
      Parameter:
      commit - The Git commit to get the abbreviated ID for
      Gibt zurück:
      The abbreviated commit ID of the given commit
      Löst aus:
      GitRepositoryException - if the abbreviated commit ID cannot be determined
    • getBranch

      public String getBranch() throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns the currently checked out branch of the Git repository
      Gibt zurück:
      The current branch of the Git repository
      Löst aus:
      GitRepositoryException - if the current branch cannot be determined
    • getDescribeCommand

      DescribeCommand getDescribeCommand()
    • getHeadCommit

      public JGitCommit getHeadCommit() throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns the current HEAD commit of the Git repository
      Gibt zurück:
      The current commit of the Git Repository
      Löst aus:
      GitRepositoryException - if the current commit cannot be determined
    • createIndexDiff

      IndexDiff createIndexDiff() throws GitRepositoryException, IOException
      Creates a new JGit IndexDiff instance for this repository and worktree
      Gibt zurück:
      A new index diff
      Löst aus:
      GitRepositoryException - if the HEAD object cannot be resolved
      IOException - if the index diff cannot be created
    • getRepositoryBuilder

      FileRepositoryBuilder getRepositoryBuilder()
      Creates a new JGit FileRepositoryBuilder instance
      Gibt zurück:
      A new repository builder
    • getTags

      public Map<String,GitTag> getTags() throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns a map of tags available in this repository

      The keys of the map are the SHA IDs of the objects referenced by the tags. The map's values are the tags themselves.

      Note: Only annotated tags referencing commit objects will be returned.

      Gibt zurück:
      A map of tags in this repository
      Löst aus:
      GitRepositoryException - if an error occurs while determining the tags in this repository
    • getWorkTree

      public File getWorkTree()
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns the worktree of the repository
      Gibt zurück:
      The worktree of the repository
    • isChecked

      public boolean isChecked()
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns whether this repository instance has been checked
      Gibt zurück:
      true if this repository has already been checked
      Siehe auch:
    • isDirty

      public boolean isDirty(boolean ignoreUntracked) throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns whether the worktree of the repository is in a clean state
      Parameter:
      ignoreUntracked - If true, untracked files in the repository will be ignored
      Gibt zurück:
      true if there are modified files in the repository's worktree
      Löst aus:
      GitRepositoryException - if an error occurs while checking the worktree state
    • isOnUnbornBranch

      public boolean isOnUnbornBranch() throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Returns whether this repository is currently on an “unborn” branch An “unborn” branch is a branch without any actual commits. This only applies when the configured head ref is actually HEAD. Otherwise a configuration error is assumed.
      Gibt zurück:
      true if the current branch is
      Löst aus:
      GitRepositoryException - if an error occurs while retrieving the current HEAD commit
    • loadTag

      public void loadTag(GitTag tag) throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Load tag meta data
      Parameter:
      tag - The tag to load information for
      Löst aus:
      GitRepositoryException - if tag metadata cannot be loaded
    • walkCommits

      public void walkCommits(CommitWalkAction action) throws GitRepositoryException
      Beschreibung aus Schnittstelle kopiert: GitRepository
      Runs the given action for all commits reachable from the current HEAD commit
      Parameter:
      action - The action to execute for each commit found
      Löst aus:
      GitRepositoryException - if an error occurs during walking through the commits
    • getHeadRevCommit

      RevCommit getHeadRevCommit() throws GitRepositoryException
      Returns a commit object for HEAD
      Gibt zurück:
      The commit object for HEAD
      Löst aus:
      GitRepositoryException - if the commit object cannot be retrieved
      Siehe auch:
    • getHeadObject

      ObjectId getHeadObject() throws GitRepositoryException
      Returns the object for the Git ref currently set as HEAD
      Gibt zurück:
      The currently selected HEAD object
      Löst aus:
      GitRepositoryException - if the ref cannot be resolved
    • getRevWalk

      RevWalk getRevWalk()
      Gibt zurück:
      A new JGit RevWalk instance for this repository
    • resolveGitDir

      private void resolveGitDir(File workTree, FileRepositoryBuilder repositoryBuilder) throws GitRepositoryException
      Löst aus:
      GitRepositoryException
    • resolveLinkedWorkTree

      private void resolveLinkedWorkTree(File workTree, File foundGitDir, FileRepositoryBuilder repositoryBuilder) throws IOException
      Löst aus:
      IOException