config: migrate output mirrors default.yml comments, literals, and examples #60
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
nagonag
nagonag/ignore
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
heiko/gogogo!60
Loading…
Reference in a new issue
No description provided.
Delete branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
default_skel.go: a lazy line-scanner (sync.Once) that parses the embeddeddefault.ymlinto three lookup maps keyed by dotted YAML path —fieldComments(),fieldLiterals(), andfieldExamples().config migrateoutput now carries the same prose comments and# Example:blocks asconfig default, sourced directly fromdefault.ymlso they can never drift.default.ymlverbatim (e.g.#section: miscnot#section: "misc").module,apiurl,owner,name,token,homepage) show the resolved runtime value commented rather than the static empty placeholder.release.branchdouble-comment andscriptssub-field indent matchingdefault.yml.wsl_v5lint issues inpackages_test.gointroduced by #56.Test plan
go test ./internal/config/...passesgolangci-lint run ./internal/config/...reports 0 issuesdiff <(gogogo config default) <(gogogo config migrate)shows only: preamble (intentionally distinct), auto-detected fields, and actual non-default repo valuesTestMigratedFieldCommentsAndExamplesexercises comment/example/auto-detection paths🤖 Generated with Claude Code
## Summary Adds full multi-package Debian/RPM support to gogogo. Three layers land in this PR: 1. **YAML schema layer** — polymorphic `artifacts.packages:` field (absent / `'*'` / list) with per-package merge and validation. 2. **Generator + rendering layer** — source-package builders emit multi-stanza `debian/control` and multi-`%package -n` `<name>.spec` files. Both honor user-edited templates in `debian/*` and `rpm/<name>.spec` via `text/template` rendering against a stable `DebContext`/`RPMContext`. 3. **CLI scaffolding** — two new subcommands: - `gogogo config packages` — scaffold the `artifacts.packages:` YAML block from `cmd/*` discovery (replaces the misnamed first version of `pack populate`). - `gogogo pack populate` — scaffold editable starter files into `debian/` and `rpm/` for users who want to customise the source-package shape beyond what the YAML schema covers. ## Behavior change Existing multi-binary projects without an `artifacts.packages:` declaration now produce **one combined `.deb`** named after the module, instead of one `.deb` per `cmd/*` binary. Set `packages: '*'` (or use `gogogo config packages --shorthand --in-place`) to preserve the prior per-binary split. ## CLI surface ```bash gogogo config packages # print packages: block to stdout gogogo config packages --shorthand # one-liner: `packages: '*'` gogogo config packages --in-place --force # splice into .gogogo.conf gogogo pack populate # scaffold editable debian/* + rpm/* stubs gogogo pack populate --force # overwrite existing stubs gogogo --version # `<cmd> <ver> <exe-path>` (new format) ``` ## User-template contract User-edited `debian/control`, `debian/rules`, `debian/changelog`, `debian/source/format`, and `rpm/<name>.spec` files are rendered through `text/template` at build time against: - `DebContext` — `Source`, `Maintainer`, `Tag`, `DebVersion`, `Packages[]`, `Synopsis`, `LongDescIndented`, `ChangelogDate`, etc. - `RPMContext` — `Name`, `RPMVersion`, `RPMRelease`, `TarName`, `Packages[]`, `Group`, `Changelog`, etc. Field names form a public stability contract. `missingkey=error` makes typos like `{{ .Versoin }}` fail loud with the offending file path in the error. ## Test plan - [x] `go test ./...` — all packages pass - [x] `go vet ./...` clean - [x] `golangci-lint run` — no new issues in any added file (intentional misspellings + `fmt.Fprintf` progress lines marked with `//nolint`) - [x] Manual: `gogogo --version`, `gogogo config packages --help`, `gogogo pack populate` end-to-end on a fixture project - [x] Source `.dsc` rebuild produces the same multi-package set as direct `.deb` build (multi-stanza `debian/control` + per-package `go build`) - [x] `rpmbuild -bs` on the generated `<name>.spec` works for both single-package (no `-n`) and multi-package (`%package -n` per entry) projects ## Commits ```1058573suppress intentional lint warnings: nolint markers for typo+errcheck9276d5fsource/rpm: multi-package %package -n + user-file render path44d992bpack populate: scaffold editable debian/* and rpm/ stub filesa4ec9e1source: render user-edited debian/* files through text/template12d2083pack populate → config packages (rename only)4bce628config/migrate: split artifacts() into per-block render helpersb55048bcli: --version prints '<cmd> <ver> <exe-path>'367aa26config: keep explanatory comments in migrate output, drop 'Example config' preamble9647a74config migrate: import existing v2 artifacts.* settings0ac9515Expand multi-package test coverage9063addAdd multi-package support for Debian and RPM artifacts ``` ## Known limitations (CHANGELOG-worthy) 1. **Behavior change**: existing multi-binary projects start producing one combined `.deb` by default. Use `packages: '*'` to preserve the prior per-binary split. 2. **Union merge semantics** on per-package list overrides mean an entry can't *remove* a globally-declared dep. If needed in practice, a `depends_remove:` escape hatch can land separately. 3. **Template stability**: once shipped, `DebContext`/`RPMContext` field names are committed — renames are breaking changes for users with custom `debian/*` or `rpm/<name>.spec` templates. ius:ai:claude-opus-4-7 Reviewed-on: #56Adds default_skel.go: a line-scanner that parses the embedded default.yml once (sync.Once) into three lookup maps keyed by dotted YAML path: - fieldComments() — prose comment lines above each field - fieldLiterals() — value text as written in default.yml - fieldExamples() — # Example: blocks attached to each field migrate.go is updated to use these maps: - scalar() gains a path parameter; when comment=true and the path has a known default literal, emits it verbatim (e.g. #section: misc not #section: "misc"). - scalarAuto() for auto-detected fields shows the resolved runtime value commented (e.g. #apiurl: "https://forgejo.example.com/api/v1"). - comment(path, indent) and example(path, indent) replace hardcoded commentLines() calls so comment text is sourced from default.yml. ius:ai:claude-sonnet-4-6default_skel.go: - Remove redundant `seen map[string]bool`; `comments` map presence already encodes the same information — use `_, already := comments[path]`. - Replace WHAT doc-comment on parseSkel with a WHY: explains why a line scanner is needed instead of yaml.v3 (commented keys aren't in the node tree). migrate.go: - security(): add missing `m.comment("security", "")` for consistency with all other top-level block renderers. - renderDebBlock(): assign IsSystemdEnabled()/IsLintianEnabled() to locals instead of calling each method twice. - scripts(): pass "" as path to scalar() calls where comment=false; the path arg is only consulted when comment=true, so the old specific paths were dead lookups. ius:ai:claude-sonnet-4-6