mirror of
https://github.com/PerpetualSoftware/pad.git
synced 2026-09-20 17:43:26 +00:00
7cda0d7896
Migrates from xarmian/pad to PerpetualSoftware/pad across the entire
repo and updates the product subtitle to "Collaborate with your AI
agents".
Go module rename
- go.mod: github.com/xarmian/pad → github.com/PerpetualSoftware/pad
- All Go imports updated across cmd/pad, internal/{cli,server,store,
models,collections,items,events,metrics,webhooks} (~130 files)
- Test fixtures with the literal repo slug ("xarmian/pad" in JSON
shapes, SSH/HTTPS git URL strings, workspace_context fixtures)
also updated, including the secondary repo entry
(xarmian/pad-web → PerpetualSoftware/pad-web — pad-web was also
moved to the org per branch context)
Docs / config
- README badges, install instructions, brew tap, Docker image, source
build path, sponsor link (sponsor link kept as personal @xarmian)
- Subtitle: "Project management for developers and AI agents." →
"Collaborate with your AI agents." (README, manifests, web layout
meta, .goreleaser homebrew description)
- CONTRIBUTING.md, SECURITY.md, skills/INSTALL.md
- .goreleaser.yaml: homebrew_casks owner, GHCR image, release github
owner, cosign cert-identity regex, comments
- .github/workflows/release.yml: tap/release comments
- deploy/k8s/deployment.yaml: container image
- docs/deployment.md: clone URL
- web/static/{site.webmanifest,manifest.json}: description
- web/src/routes/+layout.svelte: meta description + og:description
Brew tap path is PerpetualSoftware/tap/pad (CamelCase, matches
GitHub user case). GHCR image is ghcr.io/perpetualsoftware/pad
(lowercased per GHCR's URL normalization). CODEOWNERS @xarmian and
FUNDING.yml github: xarmian intentionally retained — those are the
personal maintainer / sponsor account, separate from the org repo.
Verification: go build ./..., go test ./... (all pkgs pass), web
build, and make install all clean (TASK-844, TASK-845).
119 lines
3.3 KiB
Go
119 lines
3.3 KiB
Go
package items
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"github.com/PerpetualSoftware/pad/internal/models"
|
|
)
|
|
|
|
// MigrateResult holds the outcome of field migration between collection schemas.
|
|
type MigrateResult struct {
|
|
// Fields contains the migrated field values for the target schema.
|
|
Fields map[string]any
|
|
// Dropped lists field keys that were dropped during migration (no matching target field or incompatible types).
|
|
Dropped []string
|
|
// Errors lists required target fields that have no value after migration.
|
|
Errors []string
|
|
}
|
|
|
|
// MigrateFields maps field values from a source schema to a target schema.
|
|
// Fields with matching keys and compatible types are transferred.
|
|
// Incompatible or missing fields are dropped. Required target fields without
|
|
// values after migration are reported as errors.
|
|
func MigrateFields(
|
|
currentFields map[string]any,
|
|
sourceSchema []models.FieldDef,
|
|
targetSchema []models.FieldDef,
|
|
) MigrateResult {
|
|
result := MigrateResult{
|
|
Fields: make(map[string]any),
|
|
}
|
|
|
|
// Build lookup of target fields by key
|
|
targetDefs := make(map[string]models.FieldDef)
|
|
for _, f := range targetSchema {
|
|
targetDefs[f.Key] = f
|
|
}
|
|
|
|
// Build lookup of source fields by key
|
|
sourceDefs := make(map[string]models.FieldDef)
|
|
for _, f := range sourceSchema {
|
|
sourceDefs[f.Key] = f
|
|
}
|
|
|
|
// Migrate each current field value
|
|
for key, value := range currentFields {
|
|
targetField, exists := targetDefs[key]
|
|
if !exists {
|
|
result.Dropped = append(result.Dropped, key)
|
|
continue
|
|
}
|
|
|
|
sourceField := sourceDefs[key]
|
|
migrated, ok := migrateValue(value, sourceField.Type, targetField)
|
|
if ok {
|
|
result.Fields[key] = migrated
|
|
} else {
|
|
result.Dropped = append(result.Dropped, key)
|
|
}
|
|
}
|
|
|
|
// Apply defaults for target fields not yet present
|
|
for _, f := range targetSchema {
|
|
if _, exists := result.Fields[f.Key]; exists {
|
|
continue
|
|
}
|
|
if f.Default != nil && f.Default != "" {
|
|
result.Fields[f.Key] = f.Default
|
|
} else if f.Required {
|
|
result.Errors = append(result.Errors, fmt.Sprintf("required field %q has no value", f.Key))
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
// migrateValue attempts to convert a value from sourceType to the targetField's type.
|
|
// Returns the migrated value and true if successful, or zero-value and false if incompatible.
|
|
func migrateValue(value any, sourceType string, target models.FieldDef) (any, bool) {
|
|
targetType := target.Type
|
|
|
|
// Same type — validate further for select fields
|
|
if sourceType == targetType {
|
|
if targetType == "select" && target.Options != nil {
|
|
strVal := fmt.Sprintf("%v", value)
|
|
for _, opt := range target.Options {
|
|
if opt == strVal {
|
|
return value, true
|
|
}
|
|
}
|
|
// Value not in target options — drop it
|
|
return nil, false
|
|
}
|
|
return value, true
|
|
}
|
|
|
|
// Compatible type conversions
|
|
strVal := fmt.Sprintf("%v", value)
|
|
switch {
|
|
case sourceType == "text" && targetType == "url":
|
|
return value, true
|
|
case sourceType == "url" && targetType == "text":
|
|
return value, true
|
|
case sourceType == "number" && targetType == "text":
|
|
return strVal, true
|
|
case sourceType == "select" && targetType == "text":
|
|
return strVal, true
|
|
case sourceType == "checkbox" && targetType == "text":
|
|
return strVal, true
|
|
case sourceType == "text" && targetType == "number":
|
|
if _, err := strconv.ParseFloat(strVal, 64); err == nil {
|
|
return value, true
|
|
}
|
|
return nil, false
|
|
default:
|
|
return nil, false
|
|
}
|
|
}
|