mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
section 1: Phase 1: Shell environment owner and repo working-directory
This commit is contained in:
1 parent
52b6147ed3
commit
b494ee9f4a
11 files changed
+280
-17
No files matched your search
@@ -3,6 +3,7 @@ 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 { createRepo, setRepoGitIdentityId } from '../../../src/db/queries'
|
||||
import { createInternalGitCredentialsRoutes } from '../../../src/routes/internal/git-credentials'
|
||||
import type { GitCredential } from '@opencode-manager/shared'
|
||||
|
||||
@@ -37,4 +38,54 @@ describe('internal git-credentials routes', () => {
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.json()).toEqual({})
|
||||
})
|
||||
|
||||
it('GET /gh-env includes the assigned identity env for a repo cwd', async () => {
|
||||
settingsService.updateSettings({
|
||||
gitCredentials: [
|
||||
{ name: 'github', host: 'github.com', type: 'pat', token: 'ghp_test_token' } as GitCredential,
|
||||
],
|
||||
gitIdentities: [{ id: 'identity-1', name: 'Alice', email: 'alice@example.com' }],
|
||||
})
|
||||
const repo = createRepo(db, {
|
||||
repoUrl: 'https://github.com/acme/repo.git',
|
||||
localPath: 'repo',
|
||||
defaultBranch: 'main',
|
||||
cloneStatus: 'ready',
|
||||
clonedAt: Date.now(),
|
||||
})
|
||||
setRepoGitIdentityId(db, repo.id, 'identity-1')
|
||||
|
||||
const res = await app.request(`/gh-env?cwd=${encodeURIComponent(repo.fullPath)}`)
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.json()).toEqual({
|
||||
GH_TOKEN: 'ghp_test_token',
|
||||
GITHUB_TOKEN: 'ghp_test_token',
|
||||
GIT_AUTHOR_NAME: 'Alice',
|
||||
GIT_AUTHOR_EMAIL: 'alice@example.com',
|
||||
GIT_COMMITTER_NAME: 'Alice',
|
||||
GIT_COMMITTER_EMAIL: 'alice@example.com',
|
||||
})
|
||||
})
|
||||
|
||||
it('GET /gh-env omits the identity env without an assignment', async () => {
|
||||
settingsService.updateSettings({
|
||||
gitCredentials: [
|
||||
{ name: 'github', host: 'github.com', type: 'pat', token: 'ghp_test_token' } as GitCredential,
|
||||
],
|
||||
gitIdentities: [{ id: 'identity-1', name: 'Alice', email: 'alice@example.com' }],
|
||||
})
|
||||
const repo = createRepo(db, {
|
||||
repoUrl: 'https://github.com/acme/repo.git',
|
||||
localPath: 'repo',
|
||||
defaultBranch: 'main',
|
||||
cloneStatus: 'ready',
|
||||
clonedAt: Date.now(),
|
||||
})
|
||||
|
||||
const res = await app.request(`/gh-env?cwd=${encodeURIComponent(repo.fullPath)}`)
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.json()).toEqual({ GH_TOKEN: 'ghp_test_token', GITHUB_TOKEN: 'ghp_test_token' })
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user