Replace specific error keys with the generic template:
- common.error.working_dir -> common.error.failed + Action
- common.error.load_config -> common.error.failed + Action
- common.error.build_failed -> common.error.failed + Action
- common.error.get_logs -> common.error.failed + Action
- common.error.tests_failed -> common.error.failed + Action
This reduces 5 duplicate error keys to 1 reusable template:
"Failed to {{.Action}}"
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
32 lines
842 B
Go
32 lines
842 B
Go
package ci
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/host-uk/core/pkg/i18n"
|
|
"github.com/host-uk/core/pkg/release"
|
|
)
|
|
|
|
// runChangelog generates and prints a changelog.
|
|
func runChangelog(fromRef, toRef string) error {
|
|
projectDir, err := os.Getwd()
|
|
if err != nil {
|
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "get working directory"}), err)
|
|
}
|
|
|
|
// Load config for changelog settings
|
|
cfg, err := release.LoadConfig(projectDir)
|
|
if err != nil {
|
|
return fmt.Errorf("%s: %w", i18n.T("common.error.failed", map[string]any{"Action": "load config"}), err)
|
|
}
|
|
|
|
// Generate changelog
|
|
changelog, err := release.GenerateWithConfig(projectDir, fromRef, toRef, &cfg.Changelog)
|
|
if err != nil {
|
|
return fmt.Errorf("%s: %w", i18n.T("cmd.ci.error.generate_changelog"), err)
|
|
}
|
|
|
|
fmt.Println(changelog)
|
|
return nil
|
|
}
|