Consider the fact that Git trims all lines in commit message IDEA-175002

This commit is contained in:
Kirill Likhodedov
2017-06-27 14:52:43 +03:00
parent 6a845f3593
commit 19a14ecf3f
2 changed files with 15 additions and 1 deletions
@@ -27,6 +27,7 @@ import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vcs.VcsNotifier
import com.intellij.openapi.vcs.VcsNotifier.STANDARD_NOTIFICATION
import com.intellij.util.containers.MultiMap
@@ -118,7 +119,7 @@ class GitRewordOperation(private val repository: GitRepository,
return null
}
val newCommit = newCommits.last()
if (newCommit.fullMessage != newMessage) {
if (!StringUtil.equalsIgnoreWhitespaces(newCommit.fullMessage, newMessage)) {
LOG.error("Couldn't find the reworded commit. Expected message: \n[$newMessage]\nActual message: \n[${newCommit.fullMessage}]")
return null
}
@@ -15,6 +15,7 @@
*/
package git4idea.rebase
import com.intellij.openapi.util.text.StringUtil
import git4idea.test.GitSingleRepoTest
import git4idea.test.assertLatestHistory
import git4idea.test.file
@@ -90,4 +91,16 @@ class GitRewordTest : GitSingleRepoTest() {
)
assertErrorNotification("Can't Undo Reword", "Commit has already been pushed to origin/master")
}
// IDEA-175002
fun `test reword with trailing spaces`() {
val commit = file("a").create("initial").addCommit("Wrong message").details()
val newMessage = "Subject with trailing spaces \n\nBody \nwith \nspaces."
GitRewordOperation(myRepo, commit, newMessage).execute()
val actualMessage = git("log HEAD --no-walk --pretty=%B")
assertTrue("Message reworded incorrectly. Expected:\n[$newMessage] Actual:\n[$actualMessage]",
StringUtil.equalsIgnoreWhitespaces(newMessage, actualMessage))
}
}