Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ec0a70c0c | |||
| fb98aac7d2 | |||
| 9b94c16226 | |||
| 4b92fa9245 | |||
| 82458a6289 | |||
| 309d848db5 | |||
| 757b4672d4 | |||
| 3c9e3ffa13 | |||
| 3690f31b77 | |||
| be70d65e6c |
@@ -4,7 +4,7 @@
|
|||||||
<name>MokoGitea</name>
|
<name>MokoGitea</name>
|
||||||
<org>MokoConsulting</org>
|
<org>MokoConsulting</org>
|
||||||
<description>Moko fork of Gitea - adding project board REST API endpoints and custom enhancements</description>
|
<description>Moko fork of Gitea - adding project board REST API endpoints and custom enhancements</description>
|
||||||
<version>06.16.01</version>
|
<version>06.17.00</version>
|
||||||
<version-prefix>v1.26.1+MOKO</version-prefix>
|
<version-prefix>v1.26.1+MOKO</version-prefix>
|
||||||
<license spdx="GPL-3.0-or-later">GNU General Public License v3</license>
|
<license spdx="GPL-3.0-or-later">GNU General Public License v3</license>
|
||||||
</identity>
|
</identity>
|
||||||
|
|||||||
@@ -102,11 +102,11 @@ jobs:
|
|||||||
|
|
||||||
echo 'Pulling source...'
|
echo 'Pulling source...'
|
||||||
if [ ! -d $SOURCE_DIR/.git ]; then
|
if [ ! -d $SOURCE_DIR/.git ]; then
|
||||||
git clone -b $BRANCH https://git.mokoconsulting.tech/MokoConsulting/MokoGitea-APP.git $SOURCE_DIR
|
git clone -b $BRANCH https://git.mokoconsulting.tech/MokoConsulting/MokoGitea-Fork.git $SOURCE_DIR
|
||||||
fi
|
fi
|
||||||
cd $SOURCE_DIR
|
cd $SOURCE_DIR
|
||||||
# Ensure remote points to MokoGitea-APP (not the upstream fork)
|
# Ensure remote points to MokoGitea-Fork (not the upstream fork)
|
||||||
git remote set-url origin https://git.mokoconsulting.tech/MokoConsulting/MokoGitea-APP.git 2>/dev/null || true
|
git remote set-url origin https://git.mokoconsulting.tech/MokoConsulting/MokoGitea-Fork.git 2>/dev/null || true
|
||||||
git fetch origin $BRANCH
|
git fetch origin $BRANCH
|
||||||
git reset --hard origin/$BRANCH
|
git reset --hard origin/$BRANCH
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: mokoplatform.Automation
|
# INGROUP: mokoplatform.Automation
|
||||||
# VERSION: 06.16.01
|
# VERSION: 06.17.00
|
||||||
# BRIEF: Auto-create feature branch when an issue is opened
|
# BRIEF: Auto-create feature branch when an issue is opened
|
||||||
|
|
||||||
name: "Universal: Issue Branch"
|
name: "Universal: Issue Branch"
|
||||||
|
|||||||
+4
-5
@@ -1,13 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [06.17.00] --- 2026-06-18
|
||||||
|
|
||||||
|
## [06.17.00] --- 2026-06-18
|
||||||
|
|
||||||
## [06.16.00] --- 2026-06-18
|
## [06.16.00] --- 2026-06-18
|
||||||
|
|
||||||
## [06.15.00] --- 2026-06-18
|
## [06.15.00] --- 2026-06-18
|
||||||
|
|
||||||
## [06.15.00] --- 2026-06-18
|
## [06.15.00] --- 2026-06-18
|
||||||
|
|
||||||
|
|
||||||
## [06.14.00] --- 2026-06-14
|
|
||||||
|
|
||||||
## [06.15.00] --- 2026-06-12
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
db.RegisterModel(new(RepoManifest))
|
db.RegisterModel(new(RepoMetadata))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RepoManifest stores mokoplatform manifest settings for a repository.
|
// RepoMetadata stores mokoplatform metadata settings for a repository.
|
||||||
// These fields correspond to the .mokogitea/manifest.xml schema and are
|
// These fields correspond to the .mokogitea/manifest.xml schema and are
|
||||||
// exposed via API for use by Actions workflows and the mokoplatform CLI.
|
// exposed via API for use by Actions workflows and the mokoplatform CLI.
|
||||||
type RepoManifest struct {
|
type RepoMetadata struct {
|
||||||
ID int64 `xorm:"pk autoincr"`
|
ID int64 `xorm:"pk autoincr"`
|
||||||
RepoID int64 `xorm:"UNIQUE INDEX NOT NULL 'repo_id'"`
|
RepoID int64 `xorm:"UNIQUE INDEX NOT NULL 'repo_id'"`
|
||||||
|
|
||||||
@@ -55,13 +55,13 @@ type RepoManifest struct {
|
|||||||
UpdatedUnix timeutil.TimeStamp `xorm:"UPDATED 'updated_unix'"`
|
UpdatedUnix timeutil.TimeStamp `xorm:"UPDATED 'updated_unix'"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (RepoManifest) TableName() string {
|
func (RepoMetadata) TableName() string {
|
||||||
return "repo_manifest"
|
return "repo_manifest"
|
||||||
}
|
}
|
||||||
|
|
||||||
// joomlaTypePrefix maps Joomla extension types to their element name prefixes.
|
// joomlaTypePrefix maps Joomla extension types to their element name prefixes.
|
||||||
// Plugins have no prefix in Joomla's #__extensions table — the element is the
|
// Derived from Joomla 6 source: libraries/src/Installer/Adapter/*Adapter.php
|
||||||
// lowercased, hyphen-free name, and the folder column determines the plugin group.
|
// Plugins use bare names (no prefix) — the folder column determines the plugin group.
|
||||||
var joomlaTypePrefix = map[string]string{
|
var joomlaTypePrefix = map[string]string{
|
||||||
"component": "com_",
|
"component": "com_",
|
||||||
"module": "mod_",
|
"module": "mod_",
|
||||||
@@ -71,22 +71,35 @@ var joomlaTypePrefix = map[string]string{
|
|||||||
"file": "file_",
|
"file": "file_",
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutoElementName returns the auto-constructed Joomla element name (e.g. pkg_mokowaas).
|
// cleanJoomlaElement replicates Joomla's InputFilter::clean($value, 'cmd')
|
||||||
// The name is lowercased and hyphens are removed to produce clean element names
|
// which lowercases and strips all characters except [a-z0-9._-].
|
||||||
// for the #__extensions.element column (e.g. "MokoSuiteBackup" → "pkg_mokosuitebackup").
|
func cleanJoomlaElement(name string) string {
|
||||||
func (m *RepoManifest) AutoElementName() string {
|
lower := strings.ToLower(name)
|
||||||
|
var b strings.Builder
|
||||||
|
b.Grow(len(lower))
|
||||||
|
for _, r := range lower {
|
||||||
|
if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '.' || r == '_' || r == '-' {
|
||||||
|
b.WriteRune(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AutoElementName returns the auto-constructed Joomla element name (e.g. pkg_mokosuitebackup).
|
||||||
|
// The name is lowercased and cleaned to match Joomla's InputFilter::clean('cmd') behavior.
|
||||||
|
func (m *RepoMetadata) AutoElementName() string {
|
||||||
if m.Name == "" || m.PackageType == "" {
|
if m.Name == "" || m.PackageType == "" {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
lower := strings.ToLower(strings.ReplaceAll(m.Name, "-", ""))
|
cleaned := cleanJoomlaElement(m.Name)
|
||||||
if prefix, ok := joomlaTypePrefix[m.PackageType]; ok {
|
if prefix, ok := joomlaTypePrefix[m.PackageType]; ok {
|
||||||
return prefix + lower
|
return prefix + cleaned
|
||||||
}
|
}
|
||||||
return lower
|
return cleaned
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullElementName returns the effective element name: override if set, otherwise auto-constructed.
|
// FullElementName returns the effective element name: override if set, otherwise auto-constructed.
|
||||||
func (m *RepoManifest) FullElementName() string {
|
func (m *RepoMetadata) FullElementName() string {
|
||||||
if m.ElementName != "" {
|
if m.ElementName != "" {
|
||||||
return m.ElementName
|
return m.ElementName
|
||||||
}
|
}
|
||||||
@@ -94,7 +107,7 @@ func (m *RepoManifest) FullElementName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ElementNameMismatch returns true if an override is set that differs from the auto-constructed name.
|
// ElementNameMismatch returns true if an override is set that differs from the auto-constructed name.
|
||||||
func (m *RepoManifest) ElementNameMismatch() bool {
|
func (m *RepoMetadata) ElementNameMismatch() bool {
|
||||||
if m.ElementName == "" {
|
if m.ElementName == "" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -102,9 +115,9 @@ func (m *RepoManifest) ElementNameMismatch() bool {
|
|||||||
return auto != "" && m.ElementName != auto
|
return auto != "" && m.ElementName != auto
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRepoManifest returns the manifest for a repo, or nil if none exists.
|
// GetRepoMetadata returns the metadata for a repo, or nil if none exists.
|
||||||
func GetRepoManifest(ctx context.Context, repoID int64) (*RepoManifest, error) {
|
func GetRepoMetadata(ctx context.Context, repoID int64) (*RepoMetadata, error) {
|
||||||
m := new(RepoManifest)
|
m := new(RepoMetadata)
|
||||||
has, err := db.GetEngine(ctx).Where("repo_id = ?", repoID).Get(m)
|
has, err := db.GetEngine(ctx).Where("repo_id = ?", repoID).Get(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -115,9 +128,9 @@ func GetRepoManifest(ctx context.Context, repoID int64) (*RepoManifest, error) {
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOrUpdateRepoManifest upserts a repo manifest.
|
// CreateOrUpdateRepoMetadata upserts a repo metadata.
|
||||||
func CreateOrUpdateRepoManifest(ctx context.Context, m *RepoManifest) error {
|
func CreateOrUpdateRepoMetadata(ctx context.Context, m *RepoMetadata) error {
|
||||||
existing := new(RepoManifest)
|
existing := new(RepoMetadata)
|
||||||
has, err := db.GetEngine(ctx).Where("repo_id = ?", m.RepoID).Get(existing)
|
has, err := db.GetEngine(ctx).Where("repo_id = ?", m.RepoID).Get(existing)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -131,8 +144,8 @@ func CreateOrUpdateRepoManifest(ctx context.Context, m *RepoManifest) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteRepoManifest deletes the manifest for a repo.
|
// DeleteRepoMetadata deletes the metadata for a repo.
|
||||||
func DeleteRepoManifest(ctx context.Context, repoID int64) error {
|
func DeleteRepoMetadata(ctx context.Context, repoID int64) error {
|
||||||
_, err := db.GetEngine(ctx).Where("repo_id = ?", repoID).Delete(new(RepoManifest))
|
_, err := db.GetEngine(ctx).Where("repo_id = ?", repoID).Delete(new(RepoMetadata))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1480,11 +1480,11 @@ func Routes() *web.Router {
|
|||||||
}, reqAdmin())
|
}, reqAdmin())
|
||||||
}, reqAnyRepoReader())
|
}, reqAnyRepoReader())
|
||||||
m.Combo("/metadata", reqRepoReader(unit.TypeCode)).
|
m.Combo("/metadata", reqRepoReader(unit.TypeCode)).
|
||||||
Get(repo.GetRepoManifest).
|
Get(repo.GetRepoManifestMetadata).
|
||||||
Put(reqToken(), reqAdmin(), repo.UpdateRepoManifest)
|
Put(reqToken(), reqAdmin(), repo.UpdateRepoManifestMetadata)
|
||||||
m.Combo("/manifest", reqRepoReader(unit.TypeCode)). // backward compat
|
m.Combo("/manifest", reqRepoReader(unit.TypeCode)). // backward compat
|
||||||
Get(repo.GetRepoManifest).
|
Get(repo.GetRepoManifestMetadata).
|
||||||
Put(reqToken(), reqAdmin(), repo.UpdateRepoManifest)
|
Put(reqToken(), reqAdmin(), repo.UpdateRepoManifestMetadata)
|
||||||
// MokoGitea badge engine
|
// MokoGitea badge engine
|
||||||
m.Get("/badge/{type}.svg", repo.GetRepoBadge)
|
m.Get("/badge/{type}.svg", repo.GetRepoBadge)
|
||||||
m.Get("/issue_templates", reqRepoReader(unit.TypeCode), context.ReferencesGitRepo(), repo.GetIssueTemplates)
|
m.Get("/issue_templates", reqRepoReader(unit.TypeCode), context.ReferencesGitRepo(), repo.GetIssueTemplates)
|
||||||
@@ -1663,7 +1663,7 @@ func Routes() *web.Router {
|
|||||||
// })
|
// })
|
||||||
// Repo metadata (repo-scoped custom fields)
|
// Repo metadata (repo-scoped custom fields)
|
||||||
m.Group("/metadata", func() {
|
m.Group("/metadata", func() {
|
||||||
m.Get("", repo.GetRepoMetadata)
|
m.Get("", repo.GetRepoManifestMetadata)
|
||||||
m.Put("", reqToken(), reqRepoWriter(unit.TypeCode), repo.SetRepoMetadata)
|
m.Put("", reqToken(), reqRepoWriter(unit.TypeCode), repo.SetRepoMetadata)
|
||||||
})
|
})
|
||||||
// Issue custom fields
|
// Issue custom fields
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context"
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// apiManifest is the JSON representation of a repo manifest.
|
// apiMetadata is the JSON representation of a repo manifest.
|
||||||
type apiManifest struct {
|
type apiMetadata struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Org string `json:"org"`
|
Org string `json:"org"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
@@ -34,8 +34,8 @@ type apiManifest struct {
|
|||||||
EntryPoint string `json:"entry_point"`
|
EntryPoint string `json:"entry_point"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRepoManifest returns the manifest settings for a repository.
|
// GetRepoMetadata returns the manifest settings for a repository.
|
||||||
func GetRepoManifest(ctx *context.APIContext) {
|
func GetRepoManifestMetadata(ctx *context.APIContext) {
|
||||||
// swagger:operation GET /repos/{owner}/{repo}/manifest repository repoGetManifest
|
// swagger:operation GET /repos/{owner}/{repo}/manifest repository repoGetManifest
|
||||||
// ---
|
// ---
|
||||||
// summary: Get repo manifest settings
|
// summary: Get repo manifest settings
|
||||||
@@ -46,21 +46,21 @@ func GetRepoManifest(ctx *context.APIContext) {
|
|||||||
// "$ref": "#/responses/Manifest"
|
// "$ref": "#/responses/Manifest"
|
||||||
// "404":
|
// "404":
|
||||||
// "$ref": "#/responses/notFound"
|
// "$ref": "#/responses/notFound"
|
||||||
m, err := repo_model.GetRepoManifest(ctx, ctx.Repo.Repository.ID)
|
m, err := repo_model.GetRepoMetadata(ctx, ctx.Repo.Repository.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.APIErrorInternal(err)
|
ctx.APIErrorInternal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m == nil {
|
if m == nil {
|
||||||
// Return defaults from repo metadata.
|
// Return defaults from repo metadata.
|
||||||
ctx.JSON(http.StatusOK, &apiManifest{
|
ctx.JSON(http.StatusOK, &apiMetadata{
|
||||||
Name: ctx.Repo.Repository.Name,
|
Name: ctx.Repo.Repository.Name,
|
||||||
Org: ctx.Repo.Repository.OwnerName,
|
Org: ctx.Repo.Repository.OwnerName,
|
||||||
Description: ctx.Repo.Repository.Description,
|
Description: ctx.Repo.Repository.Description,
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.JSON(http.StatusOK, &apiManifest{
|
ctx.JSON(http.StatusOK, &apiMetadata{
|
||||||
Name: m.Name,
|
Name: m.Name,
|
||||||
Org: m.Org,
|
Org: m.Org,
|
||||||
Description: m.Description,
|
Description: m.Description,
|
||||||
@@ -84,8 +84,8 @@ func GetRepoManifest(ctx *context.APIContext) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateRepoManifest updates the manifest settings for a repository.
|
// UpdateRepoMetadata updates the manifest settings for a repository.
|
||||||
func UpdateRepoManifest(ctx *context.APIContext) {
|
func UpdateRepoManifestMetadata(ctx *context.APIContext) {
|
||||||
// swagger:operation PUT /repos/{owner}/{repo}/manifest repository repoUpdateManifest
|
// swagger:operation PUT /repos/{owner}/{repo}/manifest repository repoUpdateManifest
|
||||||
// ---
|
// ---
|
||||||
// summary: Update repo manifest settings
|
// summary: Update repo manifest settings
|
||||||
@@ -96,13 +96,13 @@ func UpdateRepoManifest(ctx *context.APIContext) {
|
|||||||
// responses:
|
// responses:
|
||||||
// "200":
|
// "200":
|
||||||
// "$ref": "#/responses/Manifest"
|
// "$ref": "#/responses/Manifest"
|
||||||
var req apiManifest
|
var req apiMetadata
|
||||||
if err := json.NewDecoder(ctx.Req.Body).Decode(&req); err != nil {
|
if err := json.NewDecoder(ctx.Req.Body).Decode(&req); err != nil {
|
||||||
ctx.APIError(http.StatusBadRequest, err)
|
ctx.APIError(http.StatusBadRequest, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
m := &repo_model.RepoManifest{
|
m := &repo_model.RepoMetadata{
|
||||||
RepoID: ctx.Repo.Repository.ID,
|
RepoID: ctx.Repo.Repository.ID,
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Org: req.Org,
|
Org: req.Org,
|
||||||
@@ -126,12 +126,12 @@ func UpdateRepoManifest(ctx *context.APIContext) {
|
|||||||
EntryPoint: req.EntryPoint,
|
EntryPoint: req.EntryPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo_model.CreateOrUpdateRepoManifest(ctx, m); err != nil {
|
if err := repo_model.CreateOrUpdateRepoMetadata(ctx, m); err != nil {
|
||||||
ctx.APIErrorInternal(err)
|
ctx.APIErrorInternal(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusOK, &apiManifest{
|
ctx.JSON(http.StatusOK, &apiMetadata{
|
||||||
Name: m.Name,
|
Name: m.Name,
|
||||||
Org: m.Org,
|
Org: m.Org,
|
||||||
Description: m.Description,
|
Description: m.Description,
|
||||||
|
|||||||
@@ -65,9 +65,9 @@ func ServeChangelogXML(ctx *context.Context) {
|
|||||||
elementFromManifest := false
|
elementFromManifest := false
|
||||||
extTypeFromManifest := false
|
extTypeFromManifest := false
|
||||||
|
|
||||||
manifest, err := repo_model.GetRepoManifest(ctx, repo.ID)
|
manifest, err := repo_model.GetRepoMetadata(ctx, repo.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("ServeChangelogXML: GetRepoManifest for repo %d: %v", repo.ID, err)
|
log.Warn("ServeChangelogXML: GetRepoMetadata for repo %d: %v", repo.ID, err)
|
||||||
}
|
}
|
||||||
if manifest != nil {
|
if manifest != nil {
|
||||||
if elem := manifest.FullElementName(); elem != "" {
|
if elem := manifest.FullElementName(); elem != "" {
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ func Metadata(ctx *context.Context) {
|
|||||||
ownerID := ctx.Repo.Repository.OwnerID
|
ownerID := ctx.Repo.Repository.OwnerID
|
||||||
|
|
||||||
// Load manifest (project identity).
|
// Load manifest (project identity).
|
||||||
manifest, err := repo_model.GetRepoManifest(ctx, repoID)
|
manifest, err := repo_model.GetRepoMetadata(ctx, repoID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.ServerError("GetRepoManifest", err)
|
ctx.ServerError("GetRepoMetadata", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if manifest == nil {
|
if manifest == nil {
|
||||||
manifest = &repo_model.RepoManifest{
|
manifest = &repo_model.RepoMetadata{
|
||||||
RepoID: repoID,
|
RepoID: repoID,
|
||||||
Name: ctx.Repo.Repository.Name,
|
Name: ctx.Repo.Repository.Name,
|
||||||
Org: ctx.Repo.Repository.OwnerName,
|
Org: ctx.Repo.Repository.OwnerName,
|
||||||
@@ -68,11 +68,11 @@ func Metadata(ctx *context.Context) {
|
|||||||
func MetadataPost(ctx *context.Context) {
|
func MetadataPost(ctx *context.Context) {
|
||||||
switch ctx.FormString("action") {
|
switch ctx.FormString("action") {
|
||||||
case "manifest":
|
case "manifest":
|
||||||
saveManifest(ctx)
|
saveMetadata(ctx)
|
||||||
case "customfields":
|
case "customfields":
|
||||||
saveCustomFields(ctx)
|
saveCustomFields(ctx)
|
||||||
default:
|
default:
|
||||||
saveManifest(ctx)
|
saveMetadata(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,19 +92,18 @@ var spdxToName = map[string]string{
|
|||||||
"proprietary": "Proprietary",
|
"proprietary": "Proprietary",
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveManifest(ctx *context.Context) {
|
func saveMetadata(ctx *context.Context) {
|
||||||
spdx := ctx.FormString("license_spdx")
|
spdx := ctx.FormString("license_spdx")
|
||||||
licenseName := spdxToName[spdx]
|
licenseName := spdxToName[spdx]
|
||||||
|
|
||||||
// Preserve existing values for fields removed from the UI.
|
// Preserve existing values for fields removed from the UI.
|
||||||
existing, _ := repo_model.GetRepoManifest(ctx, ctx.Repo.Repository.ID)
|
existing, _ := repo_model.GetRepoMetadata(ctx, ctx.Repo.Repository.ID)
|
||||||
|
|
||||||
manifest := &repo_model.RepoManifest{
|
manifest := &repo_model.RepoMetadata{
|
||||||
RepoID: ctx.Repo.Repository.ID,
|
RepoID: ctx.Repo.Repository.ID,
|
||||||
Name: ctx.FormString("name"),
|
Name: ctx.FormString("name"),
|
||||||
Org: ctx.FormString("org"),
|
Org: ctx.FormString("org"),
|
||||||
Description: ctx.Repo.Repository.Description,
|
Description: ctx.Repo.Repository.Description,
|
||||||
Version: ctx.FormString("version"),
|
|
||||||
LicenseSPDX: spdx,
|
LicenseSPDX: spdx,
|
||||||
LicenseName: licenseName,
|
LicenseName: licenseName,
|
||||||
VersionPrefix: ctx.FormString("version_prefix"),
|
VersionPrefix: ctx.FormString("version_prefix"),
|
||||||
@@ -127,8 +126,8 @@ func saveManifest(ctx *context.Context) {
|
|||||||
manifest.Language = existing.Language
|
manifest.Language = existing.Language
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo_model.CreateOrUpdateRepoManifest(ctx, manifest); err != nil {
|
if err := repo_model.CreateOrUpdateRepoMetadata(ctx, manifest); err != nil {
|
||||||
ctx.ServerError("CreateOrUpdateRepoManifest", err)
|
ctx.ServerError("CreateOrUpdateRepoMetadata", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ type manifestIdentity struct {
|
|||||||
Name string `xml:"name"`
|
Name string `xml:"name"`
|
||||||
Org string `xml:"org"`
|
Org string `xml:"org"`
|
||||||
Description string `xml:"description"`
|
Description string `xml:"description"`
|
||||||
Version string `xml:"version"`
|
|
||||||
VersionPrefix string `xml:"version-prefix"`
|
VersionPrefix string `xml:"version-prefix"`
|
||||||
ElementName string `xml:"element-name"`
|
ElementName string `xml:"element-name"`
|
||||||
License manifestLicense `xml:"license"`
|
License manifestLicense `xml:"license"`
|
||||||
@@ -57,11 +56,11 @@ type manifestBuild struct {
|
|||||||
EntryPoint string `xml:"entry-point"`
|
EntryPoint string `xml:"entry-point"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncManifestFromCommit reads .mokogitea/manifest.xml from the given commit
|
// SyncMetadataFromCommit reads .mokogitea/manifest.xml from the given commit
|
||||||
// and upserts the values into the repo_manifest database table.
|
// 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
|
// 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.
|
// with the XML file. If no manifest.xml exists, this is a no-op.
|
||||||
func SyncManifestFromCommit(ctx context.Context, repo *repo_model.Repository, commit *git.Commit) {
|
func SyncMetadataFromCommit(ctx context.Context, repo *repo_model.Repository, commit *git.Commit) {
|
||||||
if commit == nil {
|
if commit == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -73,7 +72,7 @@ func SyncManifestFromCommit(ctx context.Context, repo *repo_model.Repository, co
|
|||||||
|
|
||||||
reader, err := entry.Blob().DataAsync()
|
reader, err := entry.Blob().DataAsync()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("SyncManifest: read blob for %s: %v", repo.FullName(), err)
|
log.Error("SyncMetadata: read blob for %s: %v", repo.FullName(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer reader.Close()
|
defer reader.Close()
|
||||||
@@ -81,16 +80,15 @@ func SyncManifestFromCommit(ctx context.Context, repo *repo_model.Repository, co
|
|||||||
var mxml manifestXML
|
var mxml manifestXML
|
||||||
decoder := xml.NewDecoder(reader)
|
decoder := xml.NewDecoder(reader)
|
||||||
if err := decoder.Decode(&mxml); err != nil {
|
if err := decoder.Decode(&mxml); err != nil {
|
||||||
log.Error("SyncManifest: parse XML for %s: %v", repo.FullName(), err)
|
log.Error("SyncMetadata: parse XML for %s: %v", repo.FullName(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest := &repo_model.RepoManifest{
|
manifest := &repo_model.RepoMetadata{
|
||||||
RepoID: repo.ID,
|
RepoID: repo.ID,
|
||||||
Name: mxml.Identity.Name,
|
Name: mxml.Identity.Name,
|
||||||
Org: mxml.Identity.Org,
|
Org: mxml.Identity.Org,
|
||||||
Description: mxml.Identity.Description,
|
Description: mxml.Identity.Description,
|
||||||
Version: mxml.Identity.Version,
|
|
||||||
VersionPrefix: mxml.Identity.VersionPrefix,
|
VersionPrefix: mxml.Identity.VersionPrefix,
|
||||||
ElementName: mxml.Identity.ElementName,
|
ElementName: mxml.Identity.ElementName,
|
||||||
LicenseSPDX: mxml.Identity.License.SPDX,
|
LicenseSPDX: mxml.Identity.License.SPDX,
|
||||||
@@ -109,10 +107,10 @@ func SyncManifestFromCommit(ctx context.Context, repo *repo_model.Repository, co
|
|||||||
EntryPoint: mxml.Build.EntryPoint,
|
EntryPoint: mxml.Build.EntryPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := repo_model.CreateOrUpdateRepoManifest(ctx, manifest); err != nil {
|
if err := repo_model.CreateOrUpdateRepoMetadata(ctx, manifest); err != nil {
|
||||||
log.Error("SyncManifest: save for %s: %v", repo.FullName(), err)
|
log.Error("SyncMetadata: save for %s: %v", repo.FullName(), err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("SyncManifest: synced .mokogitea/manifest.xml for %s", repo.FullName())
|
log.Info("SyncMetadata: synced .mokogitea/manifest.xml for %s", repo.FullName())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
|
|||||||
log.Error("DelRepoDivergenceFromCache: %v", err)
|
log.Error("DelRepoDivergenceFromCache: %v", err)
|
||||||
}
|
}
|
||||||
// Auto-sync .mokogitea/manifest.xml to database on default branch push
|
// Auto-sync .mokogitea/manifest.xml to database on default branch push
|
||||||
SyncManifestFromCommit(ctx, repo, newCommit)
|
SyncMetadataFromCommit(ctx, repo, newCommit)
|
||||||
// Run security scanners on default branch push
|
// Run security scanners on default branch push
|
||||||
security_service.ScanOnPush(ctx, repo, newCommit)
|
security_service.ScanOnPush(ctx, repo, newCommit)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ func resolveExtensionMetadata(ctx context.Context, repo *repo_model.Repository,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Manifest is the source of truth for extension metadata.
|
// Manifest is the source of truth for extension metadata.
|
||||||
manifest, err := repo_model.GetRepoManifest(ctx, repo.ID)
|
manifest, err := repo_model.GetRepoMetadata(ctx, repo.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("resolveExtensionMetadata: GetRepoManifest for repo %d: %v", repo.ID, err)
|
log.Error("resolveExtensionMetadata: GetRepoMetadata for repo %d: %v", repo.ID, err)
|
||||||
}
|
}
|
||||||
if manifest != nil {
|
if manifest != nil {
|
||||||
if elem := manifest.FullElementName(); elem != "" {
|
if elem := manifest.FullElementName(); elem != "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user