mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
- Create a worktree from a new or existing branch - Integrate a worktree branch into a target branch by merge commit or cherry-pick, with continue/abort on conflicts - Delete a worktree with keep, delete-local, or delete-local-and-remote branch options, using safe branch deletion for unmerged branches - Add a stash tab (list, push, apply, pop, drop) shared across a repository and its worktrees - Rename and delete branches, optionally deleting the remote branch and updating scheduled base branches - Detect in-progress merge, rebase, cherry-pick and revert operations and hand conflicts to an agent session - Generate commit messages from staged changes with the default model - Add a default git identity and saved per-repository identities written to git config - Unify git error mapping behind a typed error and one route helper; consolidate git mutations and cache invalidation - Update repository docs
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { buildConflictResolutionPrompt } from './git-conflict-prompt'
|
|
|
|
describe('buildConflictResolutionPrompt', () => {
|
|
it('names the operation, branch, and every conflicted file', () => {
|
|
const prompt = buildConflictResolutionPrompt({
|
|
operation: { kind: 'merge', conflictedFiles: ['src/a.ts', 'src/b.ts'] },
|
|
branch: 'feature/x',
|
|
})
|
|
|
|
expect(prompt).toContain('git merge')
|
|
expect(prompt).toContain('feature/x')
|
|
expect(prompt).toContain('- src/a.ts')
|
|
expect(prompt).toContain('- src/b.ts')
|
|
})
|
|
|
|
it('preserves exact unicode and special-character conflicted file names', () => {
|
|
const prompt = buildConflictResolutionPrompt({
|
|
operation: { kind: 'merge', conflictedFiles: ['café.txt', 'a b"c.txt'] },
|
|
branch: 'feature/x',
|
|
})
|
|
|
|
expect(prompt).toContain('- café.txt')
|
|
expect(prompt).toContain('- a b"c.txt')
|
|
expect(prompt).not.toContain('\\303')
|
|
expect(prompt).not.toContain('"a b\\"c.txt"')
|
|
})
|
|
|
|
it('instructs the agent to confirm the strategy before editing', () => {
|
|
const prompt = buildConflictResolutionPrompt({
|
|
operation: { kind: 'rebase', conflictedFiles: ['file.txt'] },
|
|
branch: 'main',
|
|
})
|
|
|
|
expect(prompt).toContain('Wait for the user to confirm')
|
|
expect(prompt).toContain('before editing')
|
|
})
|
|
|
|
it('uses the kind-specific continue command with a non-interactive editor', () => {
|
|
const prompt = buildConflictResolutionPrompt({
|
|
operation: { kind: 'cherry-pick', conflictedFiles: ['file.txt'] },
|
|
branch: 'main',
|
|
})
|
|
|
|
expect(prompt).toContain('GIT_EDITOR=true git cherry-pick --continue')
|
|
expect(prompt).toContain('git add')
|
|
})
|
|
|
|
it('forbids abort and force-push unless the user asks', () => {
|
|
const prompt = buildConflictResolutionPrompt({
|
|
operation: { kind: 'revert', conflictedFiles: ['file.txt'] },
|
|
branch: 'main',
|
|
})
|
|
|
|
expect(prompt).toContain('git revert --abort')
|
|
expect(prompt).toContain('force-push')
|
|
expect(prompt).toContain('unless the user explicitly asks')
|
|
})
|
|
})
|