diff --git a/plugins/git4idea/resources/messages/GitBundle.properties b/plugins/git4idea/resources/messages/GitBundle.properties index 4700e373c358..ec14ad482ea1 100644 --- a/plugins/git4idea/resources/messages/GitBundle.properties +++ b/plugins/git4idea/resources/messages/GitBundle.properties @@ -921,7 +921,7 @@ action.Git.Stage.Disable.text=Changelists action.Git.Stage.Disable.description=Disable staging area and switch to changelists branches.selected.branches.updated.title=Updated {0,choice,1#branch|2#branches}:\n\n{1} -branches.update.failed=Update Failed +branches.update.failed=Update failed branches.updating.process=Updating branches\u2026 branches.checking.existing.commits.process=Checking existing commits\u2026 branches.create.new.branch.dialog.title=Create New Branch @@ -1383,8 +1383,8 @@ error.git.version.check.failed=Error while executing ''git --version''. ExitCode local.changes.save.policy.stash=Stash local.changes.save.policy.shelve=Shelve -notification.title.fetch.failure=Fetch Failed -notification.title.fetch.success=Fetch Successful +notification.title.fetch.failure=Fetch failed +notification.title.fetch.success=Fetch successful title.sudo.command.install.git=Install Git notification.title.unstash.failed=Unstash failed diff --git a/plugins/git4idea/src/git4idea/fetch/GitFetchResult.java b/plugins/git4idea/src/git4idea/fetch/GitFetchResult.java index 2702ebd1f8ed..78c2d3dcdc90 100644 --- a/plugins/git4idea/src/git4idea/fetch/GitFetchResult.java +++ b/plugins/git4idea/src/git4idea/fetch/GitFetchResult.java @@ -1,6 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package git4idea.fetch; +import com.intellij.openapi.util.NlsContexts; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -9,7 +10,7 @@ public interface GitFetchResult { boolean showNotificationIfFailed(); - boolean showNotificationIfFailed(@NotNull @Nls String title); + boolean showNotificationIfFailed(@NotNull @NlsContexts.NotificationTitle String title); void throwExceptionIfFailed(); } diff --git a/plugins/git4idea/src/git4idea/fetch/GitFetchSupportImpl.kt b/plugins/git4idea/src/git4idea/fetch/GitFetchSupportImpl.kt index 0810ad9cfb54..b5b1f1231e88 100644 --- a/plugins/git4idea/src/git4idea/fetch/GitFetchSupportImpl.kt +++ b/plugins/git4idea/src/git4idea/fetch/GitFetchSupportImpl.kt @@ -12,6 +12,7 @@ import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.progress.ProgressManager import com.intellij.openapi.progress.util.BackgroundTaskUtil import com.intellij.openapi.project.Project +import com.intellij.openapi.util.NlsContexts.NotificationTitle import com.intellij.openapi.util.NlsSafe import com.intellij.openapi.util.Pair import com.intellij.openapi.util.registry.Registry @@ -299,15 +300,21 @@ internal class GitFetchSupportImpl(private val project: Project) : GitFetchSuppo return !isFailed } - override fun showNotificationIfFailed(title: @Nls String): Boolean { + override fun showNotificationIfFailed(title: @NotificationTitle String): Boolean { if (isFailed) doShowNotification(title) return !isFailed } - private fun doShowNotification(failureTitle: @Nls String? = null) { + private fun doShowNotification(failureTitle: @NotificationTitle String? = null) { val type = if (!isFailed) NotificationType.INFORMATION else NotificationType.ERROR + val title = if (!isFailed) { + GitBundle.message("notification.title.fetch.success") + } + else { + failureTitle ?: GitBundle.message("notification.title.fetch.failure") + } val message = buildMessage(failureTitle) - val notification = STANDARD_NOTIFICATION.createNotification(message, type) + val notification = STANDARD_NOTIFICATION.createNotification(title, message, type) notification.setDisplayId(if (!isFailed) GitNotificationIdsHolder.FETCH_RESULT else GitNotificationIdsHolder.FETCH_RESULT_ERROR) vcsNotifier.notify(notification) } @@ -331,14 +338,9 @@ internal class GitFetchSupportImpl(private val project: Project) : GitFetchSuppo } val sb = HtmlBuilder() - if (!isFailed) { - sb.append(HtmlChunk.text(GitBundle.message("notification.title.fetch.success")).bold()) - } - else { + if (isFailed && failed.size != roots.size && failed.keys.isNotEmpty()) { sb.append(HtmlChunk.text(failureTitle ?: GitBundle.message("notification.title.fetch.failure")).bold()) - if (failed.size != roots.size) { - sb.append(mention(failed.keys)) - } + sb.append(mention(failed.keys)) } appendDetails(sb, errorMessage) appendDetails(sb, prunedRefs) @@ -348,7 +350,8 @@ internal class GitFetchSupportImpl(private val project: Project) : GitFetchSuppo private fun appendDetails(sb: HtmlBuilder, details: MultiRootMessage) { val text = details.asString() if (text.isNotEmpty()) { - sb.br().append(text) + if (!sb.isEmpty) sb.br() + sb.append(text) } } } diff --git a/plugins/git4idea/tests/git4idea/fetch/GitFetchTest.kt b/plugins/git4idea/tests/git4idea/fetch/GitFetchTest.kt index dc16e0c7ad1d..70cf091269af 100644 --- a/plugins/git4idea/tests/git4idea/fetch/GitFetchTest.kt +++ b/plugins/git4idea/tests/git4idea/fetch/GitFetchTest.kt @@ -33,7 +33,7 @@ class GitFetchTest : GitPlatformTest() { cd(repo) assertEquals("The latest commit on origin/master is incorrect", hash, log("--pretty=%H -1 origin/master")) - assertSuccessfulNotification("Fetch Successful") + assertSuccessfulNotification("Fetch successful", "") } fun `test fetch specific remote`() { @@ -48,7 +48,7 @@ class GitFetchTest : GitPlatformTest() { cd(repo) assertEquals("The latest commit on second/master is incorrect", hash1, log("--pretty=%H -1 second/master")) - assertSuccessfulNotification("Fetch Successful") + assertSuccessfulNotification("Fetch successful", "") } fun `test fetch all remotes`() { @@ -64,7 +64,7 @@ class GitFetchTest : GitPlatformTest() { cd(repo) assertEquals("The latest commit on second/master is incorrect", hash1, log("--pretty=%H -1 second/master")) assertEquals("The latest commit on origin/master is incorrect", hash2, log("--pretty=%H -1 origin/master")) - assertSuccessfulNotification("Fetch Successful") + assertSuccessfulNotification("Fetch successful", "") } private fun prepareSecondRemote() : GitRemote {