From 0e7b0ac22079f4ab6dba708bb595daaa627e3285 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Mon, 20 Jul 2026 18:23:35 -0700 Subject: [PATCH] Revert "Confirm before merging a PR/MR from the sidebar strategy dropdown (#8911)" (#9636) This reverts commit 37cd830192309267e224bbbaf413a22d73de8f37. --- .../use-hosted-review-actions.test.tsx | 87 ++----------------- .../use-hosted-review-actions.ts | 28 +----- src/renderer/src/i18n/locales/en.json | 7 -- src/renderer/src/i18n/locales/es.json | 7 -- src/renderer/src/i18n/locales/ja.json | 7 -- src/renderer/src/i18n/locales/ko.json | 7 -- src/renderer/src/i18n/locales/zh.json | 7 -- 7 files changed, 8 insertions(+), 142 deletions(-) diff --git a/src/renderer/src/components/right-sidebar/use-hosted-review-actions.test.tsx b/src/renderer/src/components/right-sidebar/use-hosted-review-actions.test.tsx index 761abf269..82527dc8e 100644 --- a/src/renderer/src/components/right-sidebar/use-hosted-review-actions.test.tsx +++ b/src/renderer/src/components/right-sidebar/use-hosted-review-actions.test.tsx @@ -46,25 +46,14 @@ function makeRepo(overrides: Partial = {}): Repo { } as Repo } -type ProviderOverrides = { - review?: HostedReviewActionInfo - isGitLab?: boolean - shortLabel?: string - reviewLabel?: string -} - -function HookProbe(props: { - repo: Repo - onRefreshReview: () => Promise - overrides?: ProviderOverrides -}): null { +function HookProbe(props: { repo: Repo; onRefreshReview: () => Promise }): null { latest = useHostedReviewActions({ - review: props.overrides?.review ?? review, + review, githubPR, repo: props.repo, - isGitLab: props.overrides?.isGitLab ?? false, - shortLabel: props.overrides?.shortLabel ?? 'PR', - reviewLabel: props.overrides?.reviewLabel ?? 'pull request', + isGitLab: false, + shortLabel: 'PR', + reviewLabel: 'pull request', defaultMergeMethod: 'squash', autoMergeAction: null, onRefreshReview: props.onRefreshReview @@ -72,16 +61,12 @@ function HookProbe(props: { return null } -async function renderHook( - repo: Repo, - onRefreshReview = vi.fn().mockResolvedValue(undefined), - overrides?: ProviderOverrides -) { +async function renderHook(repo: Repo, onRefreshReview = vi.fn().mockResolvedValue(undefined)) { const container = document.createElement('div') document.body.appendChild(container) root = createRoot(container) await act(async () => { - root?.render(createElement(HookProbe, { repo, onRefreshReview, overrides })) + root?.render(createElement(HookProbe, { repo, onRefreshReview })) }) return { onRefreshReview } } @@ -155,62 +140,4 @@ describe('useHostedReviewActions', () => { expect(runtimeRpcMocks.callRuntimeRpc).not.toHaveBeenCalled() expect(onRefreshReview).toHaveBeenCalledTimes(1) }) - - it('confirms before merging with the selected strategy label (#7943)', async () => { - await renderHook(makeRepo()) - - await act(async () => { - await latest?.handleMerge('merge') - }) - - expect(confirmationMocks.confirm).toHaveBeenCalledWith( - expect.objectContaining({ - title: 'Create merge commit PR #1015?', - confirmLabel: 'Create merge commit' - }) - ) - }) - - it('does not merge when the confirmation is cancelled (#7943)', async () => { - confirmationMocks.confirm.mockResolvedValue(false) - const { onRefreshReview } = await renderHook(makeRepo()) - - await act(async () => { - await latest?.handleMerge('squash') - }) - - expect(confirmationMocks.confirm).toHaveBeenCalledTimes(1) - expect(window.api.gh.mergePR).not.toHaveBeenCalled() - expect(runtimeRpcMocks.callRuntimeRpc).not.toHaveBeenCalled() - expect(onRefreshReview).not.toHaveBeenCalled() - }) - - it('confirms GitLab MR merges with provider-aware copy (#7943)', async () => { - await renderHook(makeRepo(), undefined, { - review: { - provider: 'gitlab', - number: 42, - state: 'open', - status: 'success', - mergeable: 'MERGEABLE' - }, - isGitLab: true, - shortLabel: 'MR', - reviewLabel: 'merge request' - }) - - await act(async () => { - await latest?.handleMerge('squash') - }) - - expect(confirmationMocks.confirm).toHaveBeenCalledWith( - expect.objectContaining({ title: 'Squash and merge MR !42?' }) - ) - expect(window.api.gl.mergeMR).toHaveBeenCalledWith({ - repoPath: '/repo', - repoId: 'repo-1', - iid: 42, - method: 'squash' - }) - }) }) diff --git a/src/renderer/src/components/right-sidebar/use-hosted-review-actions.ts b/src/renderer/src/components/right-sidebar/use-hosted-review-actions.ts index 7f2274bfd..ed3a1b23b 100644 --- a/src/renderer/src/components/right-sidebar/use-hosted-review-actions.ts +++ b/src/renderer/src/components/right-sidebar/use-hosted-review-actions.ts @@ -5,7 +5,6 @@ import type { GitHubPRAutoMergeAction } from '@/components/github-pr-merge-state import type { HostedReviewInfo } from '../../../../shared/hosted-review' import type { PRInfo, Repo } from '../../../../shared/types' import type { GitHubPRMergeMethod } from '../../../../shared/types' -import { GITHUB_PR_MERGE_METHOD_LABELS } from '../../../../shared/github-pr-merge-methods' import { mergeGitHubHostedReview, setGitHubHostedReviewAutoMerge, @@ -64,21 +63,6 @@ export function useHostedReviewActions({ const handleMerge = useCallback( async (method: GitHubPRMergeMethod = defaultMergeMethod) => { - // Why: choosing a strategy from the merge dropdown must not merge on its - // own — confirm first, matching every other PR/MR merge surface (#7943). - const label = GITHUB_PR_MERGE_METHOD_LABELS[method] - const confirmed = await confirm({ - title: `${label} ${shortLabel} ${isGitLab ? '!' : '#'}${review.number}?`, - description: translate( - 'auto.components.right.sidebar.use.hosted.review.actions.e475c29b17', - 'This will merge the {{value0}}.', - { value0: reviewLabel } - ), - confirmLabel: label - }) - if (!confirmed) { - return - } setMerging(true) setActionError(null) try { @@ -106,17 +90,7 @@ export function useHostedReviewActions({ setMerging(false) } }, - [ - confirm, - githubPR?.prRepo, - isGitLab, - shortLabel, - reviewLabel, - defaultMergeMethod, - onRefreshReview, - repo, - review.number - ] + [githubPR?.prRepo, isGitLab, defaultMergeMethod, onRefreshReview, repo, review.number] ) const handleAutoMerge = useCallback(async () => { diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index 8924345d3..9d830a1aa 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -10271,13 +10271,6 @@ "cfafa92509": "No unresolved conflicts to send." } } - }, - "hosted": { - "review": { - "actions": { - "e475c29b17": "This will merge the {{value0}}." - } - } } }, "fileExplorerOperationOwner": { diff --git a/src/renderer/src/i18n/locales/es.json b/src/renderer/src/i18n/locales/es.json index 475da5a98..2bd07533c 100644 --- a/src/renderer/src/i18n/locales/es.json +++ b/src/renderer/src/i18n/locales/es.json @@ -10248,13 +10248,6 @@ "cfafa92509": "No hay conflictos sin resolver para enviar." } } - }, - "hosted": { - "review": { - "actions": { - "e475c29b17": "This will merge the {{value0}}." - } - } } }, "fileExplorerOperationOwner": { diff --git a/src/renderer/src/i18n/locales/ja.json b/src/renderer/src/i18n/locales/ja.json index c4465f1a4..c76b43af8 100644 --- a/src/renderer/src/i18n/locales/ja.json +++ b/src/renderer/src/i18n/locales/ja.json @@ -10248,13 +10248,6 @@ "cfafa92509": "送信する未解決の競合はありません。" } } - }, - "hosted": { - "review": { - "actions": { - "e475c29b17": "This will merge the {{value0}}." - } - } } }, "fileExplorerOperationOwner": { diff --git a/src/renderer/src/i18n/locales/ko.json b/src/renderer/src/i18n/locales/ko.json index a67574c5e..755bc9788 100644 --- a/src/renderer/src/i18n/locales/ko.json +++ b/src/renderer/src/i18n/locales/ko.json @@ -10248,13 +10248,6 @@ "cfafa92509": "보낼 해결되지 않은 충돌이 없습니다." } } - }, - "hosted": { - "review": { - "actions": { - "e475c29b17": "This will merge the {{value0}}." - } - } } }, "fileExplorerOperationOwner": { diff --git a/src/renderer/src/i18n/locales/zh.json b/src/renderer/src/i18n/locales/zh.json index 8a7722314..caba5e748 100644 --- a/src/renderer/src/i18n/locales/zh.json +++ b/src/renderer/src/i18n/locales/zh.json @@ -10248,13 +10248,6 @@ "cfafa92509": "没有未解决的冲突需要发送。" } } - }, - "hosted": { - "review": { - "actions": { - "e475c29b17": "This will merge the {{value0}}." - } - } } }, "fileExplorerOperationOwner": {