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
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest'
|
|
import { Database } from 'bun:sqlite'
|
|
import { migrate } from '../../../src/db/migration-runner'
|
|
import { allMigrations } from '../../../src/db/migrations'
|
|
import { SettingsService } from '../../../src/services/settings'
|
|
import { createInternalGitCredentialsRoutes } from '../../../src/routes/internal/git-credentials'
|
|
import type { GitCredential } from '@opencode-manager/shared'
|
|
|
|
describe('internal git-credentials routes', () => {
|
|
let db: Database
|
|
let settingsService: SettingsService
|
|
let app: ReturnType<typeof createInternalGitCredentialsRoutes>
|
|
|
|
beforeEach(() => {
|
|
db = new Database(':memory:')
|
|
migrate(db, allMigrations)
|
|
settingsService = new SettingsService(db)
|
|
app = createInternalGitCredentialsRoutes(db)
|
|
})
|
|
|
|
it('GET /gh-env returns GH_TOKEN and GITHUB_TOKEN for a GitHub PAT', async () => {
|
|
settingsService.updateSettings({
|
|
gitCredentials: [
|
|
{ name: 'github', host: 'github.com', type: 'pat', token: 'ghp_test_token' } as GitCredential,
|
|
],
|
|
})
|
|
|
|
const res = await app.request('/gh-env')
|
|
|
|
expect(res.status).toBe(200)
|
|
expect(await res.json()).toEqual({ GH_TOKEN: 'ghp_test_token', GITHUB_TOKEN: 'ghp_test_token' })
|
|
})
|
|
|
|
it('GET /gh-env returns an empty object when no GitHub credential exists', async () => {
|
|
const res = await app.request('/gh-env')
|
|
|
|
expect(res.status).toBe(200)
|
|
expect(await res.json()).toEqual({})
|
|
})
|
|
|
|
it('GET /gh-env returns only GH env for a repo cwd', async () => {
|
|
settingsService.updateSettings({
|
|
gitCredentials: [
|
|
{ name: 'github', host: 'github.com', type: 'pat', token: 'ghp_repo_token' } as GitCredential,
|
|
],
|
|
gitIdentities: [{ id: 'work', name: 'Work User', email: 'work@example.com' }],
|
|
})
|
|
|
|
const res = await app.request('/gh-env?cwd=/tmp/any-repo')
|
|
|
|
expect(res.status).toBe(200)
|
|
expect(await res.json()).toEqual({ GH_TOKEN: 'ghp_repo_token', GITHUB_TOKEN: 'ghp_repo_token' })
|
|
})
|
|
})
|