mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat(git): extend source control with worktrees, stashes, conflicts and identities
- 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
This commit is contained in:
1 parent
52b6147ed3
commit
53238a6324
89 files changed
+7704
-793
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { parseGitError } from '../../src/utils/git-errors'
|
||||
import { GitOperationError, parseGitError } from '../../src/utils/git-errors'
|
||||
|
||||
describe('parseGitError', () => {
|
||||
describe('AUTH_FAILED', () => {
|
||||
@@ -183,6 +183,28 @@ describe('parseGitError', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('BRANCH_NOT_MERGED', () => {
|
||||
it('matches git refusing a safe branch delete', () => {
|
||||
const error = new Error(
|
||||
"Command failed with code 1: error: the branch 'feature' is not fully merged\n" +
|
||||
"error: If you are sure you want to delete it, run 'git branch -D feature'"
|
||||
)
|
||||
const result = parseGitError(error)
|
||||
expect(result.code).toBe('BRANCH_NOT_MERGED')
|
||||
expect(result.statusCode).toBe(409)
|
||||
})
|
||||
})
|
||||
|
||||
describe('STASH_CHANGED', () => {
|
||||
it('maps the typed stale stash error to its summary', () => {
|
||||
const error = new GitOperationError('STASH_CHANGED', 'The stash list changed. Refresh and try again.')
|
||||
const result = parseGitError(error)
|
||||
expect(result.code).toBe('STASH_CHANGED')
|
||||
expect(result.statusCode).toBe(409)
|
||||
expect(result.summary).toBe('The stash list changed. Refresh and try again.')
|
||||
})
|
||||
})
|
||||
|
||||
describe('UNKNOWN', () => {
|
||||
it('falls back for unrecognized errors', () => {
|
||||
const error = new Error('Command failed with code 1: something completely unexpected happened')
|
||||
@@ -269,6 +291,30 @@ describe('parseGitError', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('GitOperationError', () => {
|
||||
it('maps a typed error by code to the table summary and status', () => {
|
||||
const error = new GitOperationError('BRANCH_IN_OTHER_WORKTREE', 'custom message')
|
||||
const result = parseGitError(error)
|
||||
|
||||
expect(result.code).toBe('BRANCH_IN_OTHER_WORKTREE')
|
||||
expect(result.summary).toBe('This branch is checked out in another worktree and cannot be modified here.')
|
||||
expect(result.statusCode).toBe(409)
|
||||
expect(result.detail).toBe('custom message')
|
||||
})
|
||||
|
||||
it('exposes typed error details', () => {
|
||||
const error = new GitOperationError('MERGE_CONFLICT', 'Integration stopped on conflicts', {
|
||||
targetRepoId: 2,
|
||||
operation: { kind: 'merge', conflictedFiles: [] },
|
||||
})
|
||||
const result = parseGitError(error)
|
||||
|
||||
expect(result.code).toBe('MERGE_CONFLICT')
|
||||
expect(result.statusCode).toBe(409)
|
||||
expect(result.details).toEqual({ targetRepoId: 2, operation: { kind: 'merge', conflictedFiles: [] } })
|
||||
})
|
||||
})
|
||||
|
||||
describe('GitService plain Error passthrough', () => {
|
||||
it('handles GitService "Repository not found" throw', () => {
|
||||
const error = new Error('Repository not found')
|
||||
|
||||
Reference in new issue
Block a user