Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swap additions and deletions in parsing git diff #295

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ val Git.changedLines: PullRequestChangedLines
val parts = line.split("\\s+".toRegex())
(parts[0].toIntOrNull() ?: 0) to (parts[1].toIntOrNull() ?: 0)
}
val additions = additionDeletionPairs.fold(0) { acc, (_, addition) -> acc + addition }
val deletions = additionDeletionPairs.fold(0) { acc, (deletion, _) -> acc + deletion }
val additions = additionDeletionPairs.fold(0) { acc, (addition, _) -> acc + addition }
val deletions = additionDeletionPairs.fold(0) { acc, (_, deletion) -> acc + deletion }
val commandRawDiffOutput = shellExecutor.execute("git diff $headSha $baseSha")
return PullRequestChangedLines(additions, deletions, commandRawDiffOutput)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package systems.danger.kotlin

import io.mockk.every
import io.mockk.mockk
import junit.framework.Assert.assertEquals
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import systems.danger.kotlin.models.git.Git
Expand Down Expand Up @@ -41,7 +41,7 @@ internal class GitKtxTest {
)
)

private val expectedResult = PullRequestChangedLines(22, 8, diffCommandOutput)
private val expectedResult = PullRequestChangedLines(8, 22, diffCommandOutput)

@Before
fun setup() {
Expand Down