From 1f71381dad6116c46ca987ee4bb599208e1b9a46 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 6 Oct 2026 19:24:49 -0600 Subject: [PATCH] repos: choose a Repo's directory; import a clone where it is A user's repos (like any Collection) may live outside the special directories, so: * New Repo has an optional Directory (relative to the media directory, empty or new). Empty still means the Repos directory. A repo in another directory is not ignored: its files are indexed unless the user ignores the directory. * Import keeps the clone where it is (no move); the inspection says whether its directory is ignored. The moved-destination checks are gone with the move. Both share the directory rules: in the media directory, not a special directory (or one holding one), nothing in config/ or tags/, and not overlapping another Collection's directory. Co-Authored-By: Claude Opus 5.5 --- app/src/api.js | 8 +- app/src/components/Repos.js | 42 ++++--- app/src/components/Repos.test.js | 17 ++- app/src/components/ThemeSamplePage.js | 3 +- modules/repos/api.py | 6 +- modules/repos/lib.py | 108 ++++++++--------- modules/repos/schema.py | 4 +- modules/repos/test/test_import.py | 164 +++++++++++--------------- 8 files changed, 164 insertions(+), 188 deletions(-) diff --git a/app/src/api.js b/app/src/api.js index c17566e3..142f7ec3 100644 --- a/app/src/api.js +++ b/app/src/api.js @@ -2529,7 +2529,7 @@ export async function getRepo(repoId) { await reposError(response, 'Failed to fetch repo.'); } -// `repo`: {url, name?, tag_name?, frequency?, mode?, branch?, description?} +// `repo`: {url, directory?, name?, tag_name?, frequency?, mode?, branch?, description?} export async function createRepo(repo) { const response = await apiPost(REPOS_API, repo); if (response.ok) { @@ -2597,8 +2597,7 @@ export function repoArchiveURL(repoId) { return `${REPOS_API}/${repoId}/archive.zip`; } -// What importing the git clone in `directory` (relative to the media directory) would do, with the URL the -// import will use. Changes nothing. +// What importing the git clone in `directory` (relative to the media directory) would do. Changes nothing. export async function inspectRepoImport(directory, name, tagName, url) { const body = {directory, name: name || null, tag_name: tagName || null, url: url || null}; const response = await apiPost(`${REPOS_API}/import/inspect`, body); @@ -2608,8 +2607,7 @@ export async function inspectRepoImport(directory, name, tagName, url) { return {error: await getErrorMessage(response, 'Cannot import this directory.')}; } -// Import an existing git clone as a Repo. `repo`: {directory, destination, confirm, url?, name?, tag_name?, ...} -// `destination` is the inspected one; the server refuses to move the clone anywhere else. +// Import an existing git clone as a Repo; it stays where it is. `repo`: {directory, confirm, url?, name?, ...} export async function importRepo(repo) { const response = await apiPost(`${REPOS_API}/import`, repo); if (response.ok) { diff --git a/app/src/components/Repos.js b/app/src/components/Repos.js index cfb76774..10d33de2 100644 --- a/app/src/components/Repos.js +++ b/app/src/components/Repos.js @@ -545,6 +545,7 @@ export function RepoNewPage() { const [branch, setBranch] = useState(''); const [submodules, setSubmodules] = useState(false); const [description, setDescription] = useState(''); + const [directory, setDirectory] = useState(''); const [submitting, setSubmitting] = useState(false); const urlIsValid = !!safeRepoHref(url.trim()); @@ -563,6 +564,7 @@ export function RepoNewPage() { branch: branch.trim() || null, submodules, description: description.trim() || null, + directory: directory.trim() || null, }); toast({type: 'success', title: 'Repo added', description: repo.name, time: 3000}); navigate(`/repos/${repo.id}`); @@ -617,6 +619,15 @@ export function RepoNewPage() { + + + setDirectory(value || '')}/> + + Optional. Empty saves it in the Repos Directory, whose files are never indexed. The + files of a repo in another directory are indexed (searchable), unless you ignore that + directory in Files. The directory must be empty. + +