mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[gitlab/github] Do not show create review notification on push in default branch
* #IDEA-336688 Fixed GitOrigin-RevId: ebf4068730d9c8ab9f0861921ec809482476aedd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
511297b5c8
commit
d1cc43e59f
@@ -108,8 +108,7 @@ public final class GitPushRepoResult {
|
||||
/**
|
||||
* Returns the branch we were pushing to, in the full-name format, e.g. {@code refs/remotes/origin/master}.
|
||||
*/
|
||||
@NotNull
|
||||
String getTargetBranch() {
|
||||
public @NotNull String getTargetBranch() {
|
||||
return myTargetBranch;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ internal class GHNotificationService(private val project: Project, parentCs: Cor
|
||||
serviceScope.launch {
|
||||
val toolWindowVm = project.serviceAsync<GHPRToolWindowViewModel>()
|
||||
val projectVm = toolWindowVm.projectVm.filterNotNull().first()
|
||||
|
||||
val defaultBranch = projectVm.defaultBranch
|
||||
if (defaultBranch != null && pushResult.targetBranch.endsWith(defaultBranch)) return@launch
|
||||
|
||||
val existingPullRequest = projectVm.isExistingPullRequest(pushResult) ?: return@launch
|
||||
if (!existingPullRequest) {
|
||||
notifyReviewCreation(project)
|
||||
|
||||
+1
@@ -40,6 +40,7 @@ class GHPRToolWindowProjectViewModel internal constructor(
|
||||
private val cs = parentCs.childScope()
|
||||
|
||||
internal val dataContext: GHPRDataContext = connection.dataContext
|
||||
val defaultBranch: String? = dataContext.repositoryDataService.defaultBranchName
|
||||
|
||||
private val allRepos = project.service<GHHostedRepositoriesManager>().knownRepositories.map(GHGitRepositoryMapping::repository)
|
||||
val repository: GHRepositoryCoordinates = dataContext.repositoryDataService.repositoryCoordinates
|
||||
|
||||
+6
-3
@@ -17,6 +17,7 @@ import git4idea.remote.hosting.changesSignalFlow
|
||||
import git4idea.repo.GitRemote
|
||||
import git4idea.repo.GitRepository
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -30,6 +31,7 @@ import org.jetbrains.plugins.gitlab.authentication.accounts.GitLabAccountManager
|
||||
import org.jetbrains.plugins.gitlab.authentication.accounts.GitLabAccountViewModel
|
||||
import org.jetbrains.plugins.gitlab.authentication.accounts.GitLabAccountViewModelImpl
|
||||
import org.jetbrains.plugins.gitlab.mergerequest.data.GitLabMergeRequestDetails
|
||||
import org.jetbrains.plugins.gitlab.mergerequest.data.GitLabProject
|
||||
import org.jetbrains.plugins.gitlab.mergerequest.diff.GitLabMergeRequestDiffViewModel
|
||||
import org.jetbrains.plugins.gitlab.mergerequest.file.GitLabMergeRequestsFilesController
|
||||
import org.jetbrains.plugins.gitlab.mergerequest.file.GitLabMergeRequestsFilesControllerImpl
|
||||
@@ -61,12 +63,13 @@ private constructor(parentCs: CoroutineScope,
|
||||
val connectionId: String = connection.id
|
||||
override val projectName: @Nls String = connection.repo.repository.projectPath.name
|
||||
|
||||
val defaultBranch: Deferred<String> = connection.projectData.defaultBranch
|
||||
|
||||
private val mergeRequestsVms = Caffeine.newBuilder().build<String, SharedFlow<Result<GitLabMergeRequestViewModels>>> { iid ->
|
||||
val projectData = connection.projectData
|
||||
projectData.mergeRequests.getShared(iid)
|
||||
connection.projectData.mergeRequests.getShared(iid)
|
||||
.transformConsecutiveSuccesses {
|
||||
mapScoped {
|
||||
GitLabMergeRequestViewModels(project, this, projectData, it, this@GitLabToolWindowProjectViewModel, connection.currentUser)
|
||||
GitLabMergeRequestViewModels(project, this, connection.projectData, it, this@GitLabToolWindowProjectViewModel, connection.currentUser)
|
||||
}
|
||||
}
|
||||
.shareIn(cs, SharingStarted.WhileSubscribed(0, 0), 1)
|
||||
|
||||
+5
-1
@@ -19,10 +19,14 @@ import org.jetbrains.plugins.gitlab.util.GitLabBundle
|
||||
internal class GitLabNotificationService(private val project: Project, parentCs: CoroutineScope) {
|
||||
private val serviceScope = parentCs.childScope(CoroutineName("GitLab notification service scope"))
|
||||
|
||||
fun showReviewCreationNotification() {
|
||||
fun showReviewCreationNotification(targetBranch: String) {
|
||||
serviceScope.launch {
|
||||
val toolWindowVm = project.serviceAsync<GitLabToolWindowViewModel>()
|
||||
val projectVm = toolWindowVm.projectVm.filterNotNull().first()
|
||||
|
||||
val defaultBranch = projectVm.defaultBranch.await()
|
||||
if (targetBranch.endsWith(defaultBranch)) return@launch
|
||||
|
||||
val mergeRequest = projectVm.mergeRequestOnCurrentBranch.first()
|
||||
if (mergeRequest == null) {
|
||||
notifyReviewCreation(project)
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ internal class GitLabPushNotificationListener(private val project: Project) : Gi
|
||||
GitPushRepoResult.Type.SUCCESS,
|
||||
GitPushRepoResult.Type.NEW_BRANCH,
|
||||
GitPushRepoResult.Type.FORCED -> {
|
||||
project.service<GitLabNotificationService>().showReviewCreationNotification()
|
||||
project.service<GitLabNotificationService>().showReviewCreationNotification(pushResult.targetBranch)
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user