Class CommitDiff
java.lang.Object
org.variantsync.diffdetective.diff.git.CommitDiff
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
PatchDiff
s 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 Summary
Modifier and TypeFieldDescriptionprivate final String
The hash of the current commit.static final String
(package private) final boolean
private final String
The hash of the parent commit.A list of allPatchDiffs
of aCommitDiff
. -
Constructor Summary
ConstructorDescriptionCommitDiff
(org.eclipse.jgit.revwalk.RevCommit commit, org.eclipse.jgit.revwalk.RevCommit parent) Creates a new diff for the following two commits. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPatchDiff
(PatchDiff patchDiff) Add aPatchDiff
.Returns this commit's hash abbreviated to the first eight characters.getAbbreviatedCommitHash
(int length) Returns the first n characters of this commit's hash.Returns the full commit hash of this commit.Returns the fill commit hash of the parent commit.int
Returns the amount ofPatchDiffs
that belong to thisCommitDiff
.Returns the list of allPatchDiffs
that belong to thisCommitDiff
.boolean
Returns true iff this commit is a merge commit.toString()
-
Field Details
-
INVALID_COMMIT_HASH
- See Also:
-
patchDiffs
A list of allPatchDiffs
of aCommitDiff
. -
parentCommitHash
The hash of the parent commit. -
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
Add aPatchDiff
. The given diff should belong to the changes between the commits of this CommitDiff.- Parameters:
patchDiff
- ThePatchDiff
to be added
-
getPatchDiffs
Returns the list of allPatchDiffs
that belong to thisCommitDiff
. -
getPatchAmount
public int getPatchAmount()Returns the amount ofPatchDiffs
that belong to thisCommitDiff
. -
isMergeCommit
public boolean isMergeCommit()Returns true iff this commit is a merge commit. -
getAbbreviatedCommitHash
Returns the first n characters of this commit's hash.- Parameters:
length
- The number of characters to include in the commit hash.
-
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
Returns the full commit hash of this commit. -
getParentCommitHash
Returns the fill commit hash of the parent commit. -
toString
-