refactor: extract CredentialProvider service and consolidate git-auth utilities (#283)

* refactor: extract CredentialProvider service and consolidate git-auth utilities

* refactor: add git-credentials route and gh env plugin, pass internal token to OpenCode

* refactor: update credential provider integration and git route

* refactor: integrate credential provider across git auth, routes, and IPC
This commit is contained in:
Chris Scott committed 2026-06-20 23:20:39 -04:00
1 parent ba08f5c24a
commit 7c8a4fe64c
31 files changed
+1136 -132

No files matched your search

+14 -2
View File
@@ -49,6 +49,7 @@ describe('GitService', () => {
let database: Database
let mockGitAuthService: GitAuthService
let mockSettingsService: any
let mockCredentialProvider: any
beforeEach(() => {
vi.clearAllMocks()
@@ -70,7 +71,10 @@ describe('GitService', () => {
},
}),
}
service = new GitService(mockGitAuthService, mockSettingsService)
mockCredentialProvider = {
getGitCredentials: vi.fn().mockReturnValue([]),
}
service = new GitService(mockGitAuthService, mockSettingsService, mockCredentialProvider)
})
describe('getStatus', () => {
@@ -639,7 +643,7 @@ describe('GitService', () => {
expect(getRepoById).toHaveBeenCalledWith(database, 1)
expect(executeCommand).toHaveBeenCalledWith(
['git', '-C', '/path/to/repo', 'push'],
{ env: expect.any(Object) }
{ env: expect.objectContaining({ OCM_GIT_REPO_ID: '1', OCM_GIT_REPO_CWD: '/path/to/repo' }) }
)
expect(result).toBe('Everything up-to-date')
})
@@ -681,6 +685,10 @@ describe('GitService', () => {
const result = await service.fetch(1, database)
expect(executeCommand).toHaveBeenCalledWith(
['git', '-C', '/path/to/repo', 'fetch', '--all', '--prune'],
{ env: expect.objectContaining({ OCM_GIT_REPO_ID: '1', OCM_GIT_REPO_CWD: '/path/to/repo' }) }
)
expect(result).toBe('')
})
})
@@ -700,6 +708,10 @@ describe('GitService', () => {
const result = await service.pull(1, database)
expect(executeCommand).toHaveBeenCalledWith(
['git', '-C', '/path/to/repo', 'pull'],
{ env: expect.objectContaining({ OCM_GIT_REPO_ID: '1', OCM_GIT_REPO_CWD: '/path/to/repo' }) }
)
expect(result).toBe('')
})
})