From 19a14ecf3f6fb7a80627646db4cd0e9312b2b5ba Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Mon, 26 Jun 2017 20:57:00 +0300 Subject: [PATCH] Consider the fact that Git trims all lines in commit message IDEA-175002 --- .../src/git4idea/rebase/GitRewordOperation.kt | 3 ++- .../git4idea/tests/git4idea/rebase/GitRewordTest.kt | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/rebase/GitRewordOperation.kt b/plugins/git4idea/src/git4idea/rebase/GitRewordOperation.kt index 4a58b21adb6c..67a9552072eb 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRewordOperation.kt +++ b/plugins/git4idea/src/git4idea/rebase/GitRewordOperation.kt @@ -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 } diff --git a/plugins/git4idea/tests/git4idea/rebase/GitRewordTest.kt b/plugins/git4idea/tests/git4idea/rebase/GitRewordTest.kt index 687e8abab4bd..5bd8b96a52c3 100644 --- a/plugins/git4idea/tests/git4idea/rebase/GitRewordTest.kt +++ b/plugins/git4idea/tests/git4idea/rebase/GitRewordTest.kt @@ -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)) + } } \ No newline at end of file