-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[patch] squishing one merge related all contribution history bug - mo…
…re remain
- Loading branch information
1 parent
e8c4376
commit a24fc36
Showing
2 changed files
with
73 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,69 @@ interface AllContributionTestSpec : SetupWithOverrides { | |
) | ||
} | ||
|
||
@Test | ||
fun `will handle merge commits on merged branches correctly`() { | ||
setupWithDefaults() | ||
val grgit = initializeGitRepo( | ||
projectDirectoryPath = projectDir.absolutePath, | ||
addFileNames = addFileNames, | ||
listOf("first"), | ||
) | ||
val firstCommit = grgit.head() | ||
|
||
val firstRelease = grgit.addTag("release") | ||
grgit.branch.add { it.name = "branch2" } | ||
grgit.checkout { it.branch = "branch2" } | ||
val secondCommit = grgit.addCommitWithMessage("second") | ||
|
||
grgit.branch.add { it.name = "branch1" } | ||
grgit.checkout { it.branch = "branch1" } | ||
grgit.addCommitWithMessage("third") | ||
|
||
grgit.checkout { it.branch = "branch2" } | ||
grgit.addCommitWithMessage("fourth") | ||
grgit.checkout { it.branch = "branch1" } | ||
grgit.addCommitWithMessage("fifth") | ||
|
||
grgit.merge { | ||
it.head = "branch2" | ||
it.setMode("no-commit") | ||
} | ||
grgit.addCommitWithMessage("merge1") | ||
|
||
grgit.checkout { it.branch = "main" } | ||
grgit.addCommitWithMessage("sixth") | ||
grgit.merge { | ||
it.head = "branch1" | ||
it.setMode("no-commit") | ||
} | ||
val merge2Commit = grgit.addCommitWithMessage("merge2") | ||
val thirdRelease = grgit.addTag("release3") | ||
|
||
val allOutput = runAllContributionData() | ||
val expectedAuthors = listOf( | ||
"[email protected]", | ||
"[email protected]", | ||
) | ||
assertEquals( | ||
listOf( | ||
toContribution( | ||
lastCommit = merge2Commit, | ||
firstCommit = secondCommit, | ||
expectedCommitCount = 7, | ||
tag = thirdRelease, | ||
expectedAuthors = expectedAuthors, | ||
), | ||
toContribution( | ||
lastCommit = firstCommit, | ||
tag = firstRelease, | ||
expectedAuthors = expectedAuthors, | ||
), | ||
), | ||
parseAll(allOutput), | ||
) | ||
} | ||
|
||
@Test | ||
fun `when merging multiple times from same branch, commits are only counted once`() { | ||
setupWithDefaults() | ||
|