From 358606e235ea5ff708c49a01f375bef0c35323a9 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 5 Jul 2026 21:00:28 -0500 Subject: [PATCH 1/2] chore(manifest): remove deprecated .mokogitea/manifest.xml parser; mokoplatform->mokocli The .mokogitea/manifest.xml file is deprecated - the first-class RepoMetadata DB fields (set via the /manifest API) are the authoritative repository metadata (see issue #752). Remove the legacy XML auto-sync path rather than teaching it the renamed mokocli root element: - delete services/repository/manifest_sync.go (manifestXML parser) - drop the SyncMetadataFromCommit call on default-branch push (push.go) - rebrand remaining mokoplatform->mokocli refs (repo_manifest.go, v347.go comment, locale manifest_desc) The RepoMetadata model, /manifest API, settings UI, and update-feed generation (first-class fields) are unchanged. gofmt-normalized repo_manifest.go struct tags. Refs #752 Claude-Session: https://claude.ai/code/session_01Wsno14cxE49MstXFs9G5KT --- models/migrations/v1_27/v347.go | 2 +- models/repo/repo_manifest.go | 42 +++++----- options/locale/locale_en-US.json | 2 +- services/repository/manifest_sync.go | 115 --------------------------- services/repository/push.go | 2 - 5 files changed, 23 insertions(+), 140 deletions(-) delete mode 100644 services/repository/manifest_sync.go diff --git a/models/migrations/v1_27/v347.go b/models/migrations/v1_27/v347.go index 44422ef710..483154fcbc 100644 --- a/models/migrations/v1_27/v347.go +++ b/models/migrations/v1_27/v347.go @@ -8,7 +8,7 @@ import ( ) // AddRepoManifestTable creates the repo_manifest table for storing -// mokoplatform manifest settings per repository. +// mokocli manifest settings per repository. func AddRepoManifestTable(x *xorm.Engine) error { type RepoManifest struct { ID int64 `xorm:"pk autoincr"` diff --git a/models/repo/repo_manifest.go b/models/repo/repo_manifest.go index 51b7d688e4..47f13cfc78 100644 --- a/models/repo/repo_manifest.go +++ b/models/repo/repo_manifest.go @@ -15,50 +15,50 @@ func init() { db.RegisterModel(new(RepoMetadata)) } -// RepoMetadata stores mokoplatform metadata settings for a repository. -// These fields correspond to the .mokogitea/manifest.xml schema and are -// exposed via API for use by Actions workflows and the mokoplatform CLI. +// RepoMetadata stores mokocli metadata settings for a repository. +// These first-class fields are the authoritative repository metadata, +// exposed via API for use by Actions workflows and mokocli. type RepoMetadata struct { - ID int64 `xorm:"pk autoincr"` - RepoID int64 `xorm:"UNIQUE INDEX NOT NULL 'repo_id'"` + ID int64 `xorm:"pk autoincr"` + RepoID int64 `xorm:"UNIQUE INDEX NOT NULL 'repo_id'"` // identity section - Name string `xorm:"TEXT 'name'"` // project name - Org string `xorm:"TEXT 'org'"` // organization name - Description string `xorm:"TEXT 'description'"` // project description + Name string `xorm:"TEXT 'name'"` // project name + Org string `xorm:"TEXT 'org'"` // organization name + Description string `xorm:"TEXT 'description'"` // project description LicenseSPDX string `xorm:"VARCHAR(50) 'license_spdx'"` // SPDX identifier, e.g. "GPL-3.0-or-later" - LicenseName string `xorm:"TEXT 'license_name'"` // human-readable license name + LicenseName string `xorm:"TEXT 'license_name'"` // human-readable license name // governance section Platform string `xorm:"VARCHAR(50) 'platform'"` // go, php, node, python, etc. - StandardsVersion string `xorm:"VARCHAR(20) 'standards_version'"` // mokoplatform standards version - StandardsSource string `xorm:"TEXT 'standards_source'"` // URL to standards repo + StandardsVersion string `xorm:"VARCHAR(20) 'standards_version'"` // mokocli standards version + StandardsSource string `xorm:"TEXT 'standards_source'"` // URL to standards repo // versioning - VersionPrefix string `xorm:"TEXT 'version_prefix'"` // tag prefix stripped for version display, e.g. "v1.26.1-moko." - ElementName string `xorm:"TEXT 'element_name'"` // full element name override, e.g. "pkg_mokowaas" (auto-constructed if empty) + VersionPrefix string `xorm:"TEXT 'version_prefix'"` // tag prefix stripped for version display, e.g. "v1.26.1-moko." + ElementName string `xorm:"TEXT 'element_name'"` // full element name override, e.g. "pkg_mokowaas" (auto-constructed if empty) // distribution metadata (used by update server feed generation) - Maintainer string `xorm:"TEXT 'maintainer'"` // maintainer/author name - MaintainerURL string `xorm:"TEXT 'maintainer_url'"` // maintainer website - InfoURL string `xorm:"TEXT 'info_url'"` // extension info/product page URL - TargetVersion string `xorm:"TEXT 'target_version'"` // target platform version regex, e.g. "(5|6)\..*" + Maintainer string `xorm:"TEXT 'maintainer'"` // maintainer/author name + MaintainerURL string `xorm:"TEXT 'maintainer_url'"` // maintainer website + InfoURL string `xorm:"TEXT 'info_url'"` // extension info/product page URL + TargetVersion string `xorm:"TEXT 'target_version'"` // target platform version regex, e.g. "(5|6)\..*" PHPMinimum string `xorm:"VARCHAR(20) 'php_minimum'"` // minimum PHP version, e.g. "8.1" // build section - Language string `xorm:"VARCHAR(50) 'language'"` // Go, PHP, TypeScript, etc. + Language string `xorm:"VARCHAR(50) 'language'"` // Go, PHP, TypeScript, etc. ExtensionType string `xorm:"VARCHAR(50) 'extension_type'"` // component, module, plugin, package, template, library, file - EntryPoint string `xorm:"TEXT 'entry_point'"` // build entry point path + EntryPoint string `xorm:"TEXT 'entry_point'"` // build entry point path // deploy section DeployHost string `xorm:"VARCHAR(255) 'deploy_host'"` // SSH host for deploy DeployPort string `xorm:"VARCHAR(10) 'deploy_port'"` // SSH port (default 2918) DeployUser string `xorm:"VARCHAR(100) 'deploy_user'"` // SSH user - DeployPath string `xorm:"TEXT 'deploy_path'"` // remote path for source/compose + DeployPath string `xorm:"TEXT 'deploy_path'"` // remote path for source/compose DockerImage string `xorm:"VARCHAR(255) 'docker_image'"` // e.g. mokoconsulting/mokogitea DockerRegistry string `xorm:"VARCHAR(255) 'docker_registry'"` // e.g. git.mokoconsulting.tech ContainerName string `xorm:"VARCHAR(100) 'container_name'"` // Docker container name - HealthURL string `xorm:"TEXT 'health_url'"` // health check URL after deploy + HealthURL string `xorm:"TEXT 'health_url'"` // health check URL after deploy CreatedUnix timeutil.TimeStamp `xorm:"INDEX CREATED 'created_unix'"` UpdatedUnix timeutil.TimeStamp `xorm:"UPDATED 'updated_unix'"` diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index a4feaf2b81..2866af1ac3 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -2772,7 +2772,7 @@ "repo.settings.support_url_help": "Shown when downloads are gated. Can point to your wiki, product page, or external support site.", "repo.settings.custom_fields": "Custom Fields", "repo.settings.manifest": "Manifest", - "repo.settings.manifest_desc": "Project identity, governance, and build settings from the MokoPlatform manifest. These are accessible via API for Actions workflows and the MokoPlatform CLI.", + "repo.settings.manifest_desc": "Project identity, governance, and build settings for the repository. These are accessible via API for Actions workflows and MokoCLI.", "repo.settings.manifest_identity": "Identity", "repo.settings.manifest_name": "Project Name", "repo.settings.manifest_element_name": "Element Name", diff --git a/services/repository/manifest_sync.go b/services/repository/manifest_sync.go deleted file mode 100644 index 3b33d9b777..0000000000 --- a/services/repository/manifest_sync.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2026 Moko Consulting -// SPDX-License-Identifier: GPL-3.0-or-later - -package repository - -import ( - "context" - "encoding/xml" - - repo_model "code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/repo" - "code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/git" - "code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/log" -) - -// manifestXML mirrors the .mokogitea/manifest.xml schema for XML parsing. -type manifestXML struct { - XMLName xml.Name `xml:"mokoplatform"` - Identity manifestIdentity `xml:"identity"` - Governance manifestGovernance `xml:"governance"` - Distribution manifestDistribution `xml:"distribution"` - Build manifestBuild `xml:"build"` -} - -type manifestDistribution struct { - DisplayName string `xml:"display-name"` - Maintainer string `xml:"maintainer"` - MaintainerURL string `xml:"maintainer-url"` - InfoURL string `xml:"info-url"` - TargetVersion string `xml:"target-version"` - PHPMinimum string `xml:"php-minimum"` -} - -type manifestIdentity struct { - Name string `xml:"name"` - Org string `xml:"org"` - Description string `xml:"description"` - VersionPrefix string `xml:"version-prefix"` - ElementName string `xml:"element-name"` - License manifestLicense `xml:"license"` -} - -type manifestLicense struct { - SPDX string `xml:"spdx,attr"` - Name string `xml:",chardata"` -} - -type manifestGovernance struct { - Platform string `xml:"platform"` - StandardsVersion string `xml:"standards-version"` - StandardsSource string `xml:"standards-source"` -} - -type manifestBuild struct { - Language string `xml:"language"` - ExtensionType string `xml:"package-type"` - EntryPoint string `xml:"entry-point"` -} - -// SyncMetadataFromCommit reads .mokogitea/manifest.xml from the given commit -// and upserts the values into the repo_manifest database table. -// This is called on push to the default branch to keep the database in sync -// with the XML file. If no manifest.xml exists, this is a no-op. -func SyncMetadataFromCommit(ctx context.Context, repo *repo_model.Repository, commit *git.Commit) { - if commit == nil { - return - } - - entry, err := commit.GetTreeEntryByPath(".mokogitea/manifest.xml") - if err != nil || entry == nil { - return // no manifest.xml — not an error - } - - reader, err := entry.Blob().DataAsync() - if err != nil { - log.Error("SyncMetadata: read blob for %s: %v", repo.FullName(), err) - return - } - defer reader.Close() - - var mxml manifestXML - decoder := xml.NewDecoder(reader) - if err := decoder.Decode(&mxml); err != nil { - log.Error("SyncMetadata: parse XML for %s: %v", repo.FullName(), err) - return - } - - manifest := &repo_model.RepoMetadata{ - RepoID: repo.ID, - Name: mxml.Identity.Name, - Org: mxml.Identity.Org, - Description: mxml.Identity.Description, - VersionPrefix: mxml.Identity.VersionPrefix, - ElementName: mxml.Identity.ElementName, - LicenseSPDX: mxml.Identity.License.SPDX, - LicenseName: mxml.Identity.License.Name, - Platform: mxml.Governance.Platform, - StandardsVersion: mxml.Governance.StandardsVersion, - StandardsSource: mxml.Governance.StandardsSource, - Maintainer: mxml.Distribution.Maintainer, - MaintainerURL: mxml.Distribution.MaintainerURL, - InfoURL: mxml.Distribution.InfoURL, - TargetVersion: mxml.Distribution.TargetVersion, - PHPMinimum: mxml.Distribution.PHPMinimum, - Language: mxml.Build.Language, - ExtensionType: mxml.Build.ExtensionType, - EntryPoint: mxml.Build.EntryPoint, - } - - if err := repo_model.CreateOrUpdateRepoMetadata(ctx, manifest); err != nil { - log.Error("SyncMetadata: save for %s: %v", repo.FullName(), err) - return - } - - log.Info("SyncMetadata: synced .mokogitea/manifest.xml for %s", repo.FullName()) -} diff --git a/services/repository/push.go b/services/repository/push.go index efc9134c3b..fdf99d821d 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -194,8 +194,6 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error { if err := DelRepoDivergenceFromCache(ctx, repo.ID); err != nil { log.Error("DelRepoDivergenceFromCache: %v", err) } - // Auto-sync .mokogitea/manifest.xml to database on default branch push - SyncMetadataFromCommit(ctx, repo, newCommit) // Run security scanners on default branch push security_service.ScanOnPush(ctx, repo, newCommit) } else { -- 2.52.0 From fcf33d35dfefbb940fef067afa5a377e732c7b56 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 5 Jul 2026 21:07:05 -0500 Subject: [PATCH 2/2] chore(api): remove /manifest backward-compat alias route (use /metadata) The /manifest GET+PUT routes were backward-compat aliases for the canonical /metadata routes. Completing the manifest->metadata migration (#752): drop the alias so /metadata is the single path. Handlers (GetRepoMetadata/UpdateRepoMetadata) are unchanged. The MCP already calls /metadata (mcp-mokogitea-api v1.4.2, gitea_metadata_get/update); the stale gitea_manifest_* tools only exist in older deployed MCP builds and drop out on redeploy. Refs #752 Claude-Session: https://claude.ai/code/session_01Wsno14cxE49MstXFs9G5KT --- routers/api/v1/api.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 855fac6acb..425b033c83 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -1543,8 +1543,6 @@ func Routes() *web.Router { }, reqAnyRepoReader()) m.Get("/metadata", repo.GetRepoMetadata) m.Put("/metadata", reqToken(), reqAdmin(), repo.UpdateRepoMetadata) - m.Get("/manifest", repo.GetRepoMetadata) // backward compat - m.Put("/manifest", reqToken(), reqAdmin(), repo.UpdateRepoMetadata) // MokoGitea badge engine m.Get("/badge/{type}.svg", repo.GetRepoBadge) m.Get("/issue_templates", reqRepoReader(unit.TypeCode), context.ReferencesGitRepo(), repo.GetIssueTemplates) -- 2.52.0