Phase 5 part 1: read a site's section types and pages

Sites → Sections and pages reads the website's Hugo repository: each
section type with the README's description, the fields in use and the
layout's, the pages using it and a real example; the pages and their
sections; the latest commits. Working copies are now held by one job at a
time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 13:52:35 -07:00
co-authored by Claude Opus 5.5
parent 00e6deee00
commit 1152cd448b
15 changed files with 958 additions and 11 deletions
+8 -4
View File
@@ -524,9 +524,10 @@ func (ap *Applier) Apply(ctx context.Context, d *db.DB, id int64) error {
return err
}
// workingCopy is a fresh copy of the site's published branch, with the
// repository's full name and that branch.
func (ap *Applier) workingCopy(ctx context.Context) (*hugorepo.Repo, string, string, error) {
// WorkingCopy is a fresh copy of the site's published branch, with the
// repository's full name and that branch. The copy is held for the caller,
// who must Release it.
func (ap *Applier) WorkingCopy(ctx context.Context) (*hugorepo.Repo, string, string, error) {
if ap.Gitea == nil {
return nil, "", "", errors.New("save a Gitea token under Settings → Search engines first")
}
@@ -547,7 +548,9 @@ func (ap *Applier) workingCopy(ctx context.Context) (*hugorepo.Repo, string, str
}
wc := &hugorepo.Repo{Dir: filepath.Join(ap.ReposDir, strings.ReplaceAll(full, "/", "__")), CloneURL: repo.CloneURL,
Token: ap.Gitea.Token(), Branch: branch, Author: ap.Author}
wc.Acquire()
if err := wc.Sync(ctx); err != nil {
wc.Release()
return nil, "", "", err
}
return wc, full, branch, nil
@@ -568,10 +571,11 @@ func buildCheck(ctx context.Context, wc *hugorepo.Repo) (bool, string) {
}
func (ap *Applier) apply(ctx context.Context, d *db.DB, c *Change) error {
wc, full, branch, err := ap.workingCopy(ctx)
wc, full, branch, err := ap.WorkingCopy(ctx)
if err != nil {
return err
}
defer wc.Release()
u, err := url.Parse(c.Page)
if err != nil {
return err