Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions backend/src/db/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Repo, CreateRepoInput } from '../types/repo'
import { getReposPath } from '@opencode-manager/shared/config/env'
import { ASSISTANT_REPO_ID, ASSISTANT_REPO_PATH, getRepoDisplayName } from '@opencode-manager/shared/utils'
import { getErrorMessage } from '../utils/error-utils'
import { canonicalPathSync } from '../utils/fs-safe'
import path from 'path'

interface RepoRow {
Expand Down Expand Up @@ -93,12 +94,12 @@ export function setRepoSandboxGitCredentials(db: Database, repoId: number, allow
}

export function getRepoByDirectory(db: Database, directory: string): Repo | null {
const resolvedDirectory = path.resolve(directory)
const resolvedDirectory = canonicalPathSync(path.resolve(directory))
const repos = listRepos(db)

return repos
.filter((repo) => {
const resolvedRepoPath = path.resolve(repo.fullPath)
const resolvedRepoPath = canonicalPathSync(path.resolve(repo.fullPath))
const relativePath = path.relative(resolvedRepoPath, resolvedDirectory)
return relativePath === '' || (!!relativePath && !relativePath.startsWith('..') && !path.isAbsolute(relativePath))
})
Expand Down
5 changes: 5 additions & 0 deletions backend/src/db/schedules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ export function updateScheduleJobRunState(db: Database, repoId: number, jobId: n
stmt.run(values.lastRunAt, values.nextRunAt ?? null, Date.now(), repoId, jobId)
}

export function updateScheduleJobsBranch(db: Database, repoId: number, from: string, to: string): number {
const stmt = db.prepare('UPDATE schedule_jobs SET branch = ?, updated_at = ? WHERE repo_id = ? AND branch = ?')
return stmt.run(to, Date.now(), repoId, from).changes
}

export function createScheduleRun(
db: Database,
input: {
Expand Down
5 changes: 1 addition & 4 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import { opencodeServerManager } from './services/opencode-single-server'
import { createOpenCodeClient } from './services/opencode/client'
import { NotificationService } from './services/notification'
import { ScheduleRunner, ScheduleService } from './services/schedules'
import { CredentialProvider } from './services/credential-provider'
import { ScheduleWorktreeManager } from './services/schedule-worktree'
import { migrateGlobalSkills } from './services/skills'
import { installAssistantWorkspace } from './services/assistant-mode'
Expand Down Expand Up @@ -220,9 +219,7 @@ try {
logger.error('Failed to initialize workspace:', error)
}

const settingsServiceForSchedules = new SettingsService(db)
const credentialProvider = new CredentialProvider(db)
const scheduleWorktreeManager = new ScheduleWorktreeManager(gitAuthService, settingsServiceForSchedules, credentialProvider, db)
const scheduleWorktreeManager = new ScheduleWorktreeManager(gitAuthService, db)
const scheduleService = new ScheduleService(db, openCodeClient, scheduleWorktreeManager)
const scheduleRunnerInstance = new ScheduleRunner(scheduleService)

Expand Down
3 changes: 2 additions & 1 deletion backend/src/routes/internal/git-credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export function createInternalGitCredentialsRoutes(db: Database) {

app.get('/gh-env', (c) => {
const provider = new CredentialProvider(db)
return c.json(provider.getGhCliEnv({ cwd: c.req.query('cwd') }))
const cwd = c.req.query('cwd')
return c.json(provider.getGhCliEnv({ cwd }))
})

return app
Expand Down
Loading
Loading