mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(git): guard remote branch deletion and skip applied cherry-picks
- Delete a remote branch only when the upstream (read from branch.<name>.remote and branch.<name>.merge) has the same name; otherwise refuse with REMOTE_BRANCH_MISMATCH before deleting anything. - Without force, require the branch to be merged into HEAD before deleting its remote branch, so pushed unmerged commits are not lost. - Cherry-pick integration selects only commits not yet applied to the target and skips merge commits. - Create worktrees from a remote-only base as origin/<branch>. - Show the upstream name in the branch delete dialog and update the worktree delete option text and git docs.
This commit is contained in:
1 parent
53238a6324
commit
84e14c4600
10 files changed
+231
-25
No files matched your search
@@ -72,4 +72,21 @@ describe('BranchesTab', () => {
|
||||
|
||||
expect(screen.getByRole('textbox', { name: 'New name for branch feature' })).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows the upstream branch name in the delete dialog', async () => {
|
||||
vi.mocked(listBranches).mockResolvedValue({
|
||||
branches: [
|
||||
{ name: 'main', type: 'local', current: true },
|
||||
{ name: 'feature', type: 'local', current: false, upstream: 'origin/feature' },
|
||||
],
|
||||
status: { ahead: 0, behind: 0 },
|
||||
})
|
||||
const user = userEvent.setup()
|
||||
render(<BranchesTab repoId={1} currentBranch="main" />, { wrapper: createWrapper() })
|
||||
|
||||
await user.click(await screen.findByRole('button', { name: 'Actions for feature' }))
|
||||
await user.click(await screen.findByRole('menuitem', { name: 'Delete' }))
|
||||
|
||||
expect(await screen.findByText('origin/feature')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
@@ -423,7 +423,8 @@ export function BranchesTab({ repoId, currentBranch }: BranchesTabProps) {
|
||||
checked={deleteRemote}
|
||||
onCheckedChange={(checked) => setDeleteRemote(checked === true)}
|
||||
/>
|
||||
Also delete remote branch
|
||||
Also delete remote branch{' '}
|
||||
<span className="font-mono">{branchToDelete.upstream}</span>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user