Class CommitDiff

java.lang.Object
org.variantsync.diffdetective.diff.git.CommitDiff

public class CommitDiff extends Object
Represents the changes made by a commit relative to another commit. A CommitDiff stores the current commit's id as well as we parent commit id. The diff represents the changes made by the current comment to the parent commit. The changes are represented by a list of PatchDiffs as a commit modifies a set of files. This is a data class that does not provide functionality.
Author:
Sören Viegener, Paul Bittner
  • Field Details

    • INVALID_COMMIT_HASH

      public static final String INVALID_COMMIT_HASH
      See Also:
    • patchDiffs

      private final List<PatchDiff> patchDiffs
      A list of all PatchDiffs of a CommitDiff.
    • parentCommitHash

      private final String parentCommitHash
      The hash of the parent commit.
    • commitHash

      private final String commitHash
      The hash of the current commit.
    • merge

      final boolean merge
  • Constructor Details

    • CommitDiff

      public CommitDiff(org.eclipse.jgit.revwalk.RevCommit commit, org.eclipse.jgit.revwalk.RevCommit parent)
      Creates a new diff for the following two commits. The resulting CommitDiff is empty meaning that it does not contain any PatchDiffs.
      Parameters:
      commit - The commit whose changes are stored relative to parent.
      parent - The commit to which changes are compared.
      See Also:
  • Method Details

    • addPatchDiff

      public void addPatchDiff(PatchDiff patchDiff)
      Add a PatchDiff. The given diff should belong to the changes between the commits of this CommitDiff.
      Parameters:
      patchDiff - The PatchDiff to be added
    • getPatchDiffs

      public List<PatchDiff> getPatchDiffs()
      Returns the list of all PatchDiffs that belong to this CommitDiff.
    • getPatchAmount

      public int getPatchAmount()
      Returns the amount of PatchDiffs that belong to this CommitDiff.
    • isMergeCommit

      public boolean isMergeCommit()
      Returns true iff this commit is a merge commit.
    • getAbbreviatedCommitHash

      public String getAbbreviatedCommitHash(int length)
      Returns the first n characters of this commit's hash.
      Parameters:
      length - The number of characters to include in the commit hash.
    • getAbbreviatedCommitHash

      public String getAbbreviatedCommitHash()
      Returns this commit's hash abbreviated to the first eight characters. The first eight characters are usually unique if a commit history does not become too large.
    • getCommitHash

      public String getCommitHash()
      Returns the full commit hash of this commit.
    • getParentCommitHash

      public String getParentCommitHash()
      Returns the fill commit hash of the parent commit.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object