mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
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:
1 parent
ba08f5c24a
commit
7c8a4fe64c
31 files changed
+1136
-132
No files matched your search
@@ -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('')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user