mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
feat: add repo rename capability with custom name field (#294)
* feat: add repo rename capability with custom name field Add a custom name field to repos, allowing users to set a display name independent of the repo URL or path. Includes a migration, PATCH endpoint, rename dialog, and display name consolidation. - DB migration 014 adds name column to repos table - PATCH /api/repos/:id endpoint with Zod validation - RenameRepoDialog component with clear/reset support - RepoRowActions gains Rename action in both dropdown and inline modes - getRepoDisplayName() consolidated to accept a repo object and prefer name - All repo name display call sites updated to use the new API * fix: add DialogTitle to RenameRepoDialog for a11y compliance * refactor: extract getRepoDisplayName to shared utils, fix schedule cache invalidation on rename
This commit is contained in:
1 parent
01e50a7019
commit
6a4e8734f9
33 files changed
+535
-84
No files matched your search
@@ -1,12 +1,13 @@
|
||||
import type { Database } from 'bun:sqlite'
|
||||
import type { Repo, CreateRepoInput } from '../types/repo'
|
||||
import { getReposPath } from '@opencode-manager/shared/config/env'
|
||||
import { ASSISTANT_REPO_ID, ASSISTANT_REPO_PATH } from '@opencode-manager/shared/utils'
|
||||
import { ASSISTANT_REPO_ID, ASSISTANT_REPO_PATH, getRepoDisplayName } from '@opencode-manager/shared/utils'
|
||||
import { getErrorMessage } from '../utils/error-utils'
|
||||
import path from 'path'
|
||||
|
||||
interface RepoRow {
|
||||
id: number
|
||||
name?: string
|
||||
repo_url?: string
|
||||
local_path: string
|
||||
source_path?: string
|
||||
@@ -28,6 +29,7 @@ function rowToRepo(row: RepoRow): Repo {
|
||||
|
||||
return {
|
||||
id: row.id,
|
||||
name: row.name ?? undefined,
|
||||
repoUrl: row.repo_url,
|
||||
localPath: row.local_path,
|
||||
fullPath,
|
||||
@@ -285,10 +287,8 @@ export function listRepos(db: Database, repoOrder?: number[]): Repo[] {
|
||||
return [...orderedRepos, ...remainingRepos]
|
||||
}
|
||||
|
||||
function getRepoName(repo: Repo): string {
|
||||
return repo.repoUrl
|
||||
? repo.repoUrl.split('/').slice(-1)[0]?.replace('.git', '') || repo.localPath
|
||||
: repo.sourcePath ? path.basename(repo.sourcePath) : repo.localPath
|
||||
export function getRepoName(repo: Repo): string {
|
||||
return getRepoDisplayName(repo)
|
||||
}
|
||||
|
||||
export function updateRepoStatus(db: Database, id: number, cloneStatus: Repo['cloneStatus']): void {
|
||||
@@ -331,6 +331,14 @@ export function updateRepoBranch(db: Database, id: number, branch: string): void
|
||||
}
|
||||
}
|
||||
|
||||
export function updateRepoName(db: Database, id: number, name: string | null): void {
|
||||
const stmt = db.prepare('UPDATE repos SET name = ? WHERE id = ?')
|
||||
const result = stmt.run(name, id)
|
||||
if (result.changes === 0) {
|
||||
throw new Error(`Repository with id ${id} not found`)
|
||||
}
|
||||
}
|
||||
|
||||
export function deleteRepo(db: Database, id: number): void {
|
||||
if (id === ASSISTANT_REPO_ID) {
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user