mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-349635 git: split notification message into 'title + content'
GitOrigin-RevId: c0d45ba9e392734e1891e62ad68c5429a70c424f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c28e76510b
commit
158f5ee2f1
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("<b>Fetch Successful</b>")
|
||||
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("<b>Fetch Successful</b>")
|
||||
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("<b>Fetch Successful</b>")
|
||||
assertSuccessfulNotification("Fetch successful", "")
|
||||
}
|
||||
|
||||
private fun prepareSecondRemote() : GitRemote {
|
||||
|
||||
Reference in New Issue
Block a user