Class PatchDiff

java.lang.Object
org.variantsync.diffdetective.diff.git.PatchDiff
All Implemented Interfaces:
GitPatch, TextBasedDiff, VariationDiffSource

public class PatchDiff extends Object implements GitPatch
Data class containing information about a single patch (i.e., the differences in a single file). Contains a VariationDiff of the patch.
Author:
Sören Viegener, Paul Bittner
  • Field Details

    • fullDiff

      private final String fullDiff
    • variationDiff

      private final VariationDiff<DiffLinesLabel> variationDiff
    • commitDiff

      private final CommitDiff commitDiff
      The commit the patch belongs to.
    • changeType

      private final org.eclipse.jgit.diff.DiffEntry.ChangeType changeType
      The general change type of a single file. See Type.
    • oldPath

      private final String oldPath
      Path of the file before modification.
    • newPath

      private final String newPath
      Path of the file after modification.
  • Constructor Details

    • PatchDiff

      public PatchDiff(CommitDiff commitDiff, org.eclipse.jgit.diff.DiffEntry diffEntry, String fullDiff, VariationDiff<DiffLinesLabel> variationDiff)
      Creates a new PatchDiff.
      Parameters:
      commitDiff - The changes of a commit this patch belongs to.
      diffEntry - The diff entry from jgit from which this PatchDiff was produced.
      fullDiff - The diff of this patch as text. Might be empty.
      variationDiff - The VariationDiff that describes this patch.
  • Method Details

    • getCommitDiff

      public CommitDiff getCommitDiff()
      Returns the corresponding CommitDiff, which this patch is part of.
    • getFileExtension

      public String getFileExtension(Time time)
      Returns the extension of the file this patch is modifying.
    • getChangeType

      public org.eclipse.jgit.diff.DiffEntry.ChangeType getChangeType()
      Description copied from interface: GitPatch
      Returns the change type of this patch (e.g., file insertion or modification).
      Specified by:
      getChangeType in interface GitPatch
    • getFileName

      public String getFileName(Time time)
      Description copied from interface: GitPatch
      Returns the name of the patched file at the given time.
      Specified by:
      getFileName in interface GitPatch
    • getCommitHash

      public String getCommitHash()
      Description copied from interface: GitPatch
      Returns the hash of the commit introducing the change.
      Specified by:
      getCommitHash in interface GitPatch
    • getParentCommitHash

      public String getParentCommitHash()
      Description copied from interface: GitPatch
      Returns the hash of the parent commit regarding which the diff was created.
      Specified by:
      getParentCommitHash in interface GitPatch
    • getDiff

      public String getDiff()
      Description copied from interface: TextBasedDiff
      Returns this diff as plain text.
      Specified by:
      getDiff in interface TextBasedDiff
    • getVariationDiff

      public VariationDiff<DiffLinesLabel> getVariationDiff()
      Returns the VariationDiff for this patch.
    • isValid

      public boolean isValid()
      Returns whether this PatchDiff is a valid patch. A patch is valid if it has a VariationDiff.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • shallowClone

      public GitPatch shallowClone()
      Description copied from interface: GitPatch
      Creates a shallow clone. A shallow clone should return the very same values for the methods of this interface. Other behaviour is unspecified.
      Specified by:
      shallowClone in interface GitPatch
      Returns:
      A clone that acts equal with respect to this interface.