- Change module from forge.lthn.ai/core/go to forge.lthn.ai/core/cli - Remove pkg/ directory (now served from core/go) - Add require + replace for forge.lthn.ai/core/go => ../go - Update go.work to include ../go workspace module - Fix all internal/cmd/* imports: pkg/ refs → forge.lthn.ai/core/go/pkg/ - Rename internal/cmd/sdk package to sdkcmd (avoids conflict with pkg/sdk) - Remove SDK library files from internal/cmd/sdk/ (now in core/go/pkg/sdk/) - Remove duplicate RAG helper functions from internal/cmd/rag/ - Remove stale cmd/core-ide/ (now in core/ide repo) - Update IDE variant to remove core-ide import - Fix test assertion for new module name - Run go mod tidy to sync dependencies core/cli is now a pure CLI application importing core/go for packages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Claude <developers@lethean.io> Reviewed-on: #1
57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package ci
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"forge.lthn.ai/core/go/pkg/cli"
|
|
"forge.lthn.ai/core/go/pkg/i18n"
|
|
"forge.lthn.ai/core/go/pkg/release"
|
|
)
|
|
|
|
func runChangelog(fromRef, toRef string) error {
|
|
cwd, err := os.Getwd()
|
|
if err != nil {
|
|
return cli.Err("%s: %w", i18n.T("i18n.fail.get", "working directory"), err)
|
|
}
|
|
|
|
// Auto-detect refs if not provided
|
|
if fromRef == "" || toRef == "" {
|
|
tag, err := latestTag(cwd)
|
|
if err == nil {
|
|
if fromRef == "" {
|
|
fromRef = tag
|
|
}
|
|
if toRef == "" {
|
|
toRef = "HEAD"
|
|
}
|
|
} else {
|
|
// No tags, use initial commit? Or just HEAD?
|
|
cli.Text(i18n.T("cmd.ci.changelog.no_tags"))
|
|
return nil
|
|
}
|
|
}
|
|
|
|
cli.Print("%s %s..%s\n\n", releaseDimStyle.Render(i18n.T("cmd.ci.changelog.generating")), fromRef, toRef)
|
|
|
|
// Generate changelog
|
|
changelog, err := release.Generate(cwd, fromRef, toRef)
|
|
if err != nil {
|
|
return cli.Err("%s: %w", i18n.T("i18n.fail.generate", "changelog"), err)
|
|
}
|
|
|
|
cli.Text(changelog)
|
|
|
|
return nil
|
|
}
|
|
|
|
func latestTag(dir string) (string, error) {
|
|
cmd := exec.Command("git", "describe", "--tags", "--abbrev=0")
|
|
cmd.Dir = dir
|
|
out, err := cmd.Output()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return strings.TrimSpace(string(out)), nil
|
|
}
|