Class PatchDiff
java.lang.Object
org.variantsync.diffdetective.diff.git.PatchDiff
- All Implemented Interfaces:
GitPatch
,TextBasedDiff
,VariationDiffSource
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.variantsync.diffdetective.diff.git.GitPatch
GitPatch.SimpleGitPatch
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.eclipse.jgit.diff.DiffEntry.ChangeType
The general change type of a single file.private final CommitDiff
The commit the patch belongs to.private final String
private final String
Path of the file after modification.private final String
Path of the file before modification.private final VariationDiff<DiffLinesLabel>
Fields inherited from interface org.variantsync.diffdetective.variation.diff.source.VariationDiffSource
Unknown
-
Constructor Summary
ConstructorDescriptionPatchDiff
(CommitDiff commitDiff, org.eclipse.jgit.diff.DiffEntry diffEntry, String fullDiff, VariationDiff<DiffLinesLabel> variationDiff) Creates a new PatchDiff. -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.jgit.diff.DiffEntry.ChangeType
Returns the change type of this patch (e.g., file insertion or modification).Returns the corresponding CommitDiff, which this patch is part of.Returns the hash of the commit introducing the change.getDiff()
Returns this diff as plain text.getFileExtension
(Time time) Returns the extension of the file this patch is modifying.getFileName
(Time time) Returns the name of the patched file at the given time.Returns the hash of the parent commit regarding which the diff was created.Returns the VariationDiff for this patch.boolean
isValid()
Returns whether this PatchDiff is a valid patch.Creates a shallow clone.toString()
-
Field Details
-
fullDiff
-
variationDiff
-
commitDiff
The commit the patch belongs to. -
changeType
private final org.eclipse.jgit.diff.DiffEntry.ChangeType changeTypeThe general change type of a single file. SeeType
. -
oldPath
Path of the file before modification. -
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
- TheVariationDiff
that describes this patch.
-
-
Method Details
-
getCommitDiff
Returns the corresponding CommitDiff, which this patch is part of. -
getFileExtension
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 interfaceGitPatch
-
getFileName
Description copied from interface:GitPatch
Returns the name of the patched file at the given time.- Specified by:
getFileName
in interfaceGitPatch
-
getCommitHash
Description copied from interface:GitPatch
Returns the hash of the commit introducing the change.- Specified by:
getCommitHash
in interfaceGitPatch
-
getParentCommitHash
Description copied from interface:GitPatch
Returns the hash of the parent commit regarding which the diff was created.- Specified by:
getParentCommitHash
in interfaceGitPatch
-
getDiff
Description copied from interface:TextBasedDiff
Returns this diff as plain text.- Specified by:
getDiff
in interfaceTextBasedDiff
-
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
-
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 interfaceGitPatch
- Returns:
- A clone that acts equal with respect to this interface.
-