[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/update/RFC.md fully. Find ONE featu... #7
3 changed files with 16 additions and 4 deletions
5
cmd.go
5
cmd.go
|
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"forge.lthn.ai/core/cli/pkg/cli"
|
||||
"github.com/spf13/cobra"
|
||||
|
|
@ -46,7 +45,7 @@ Examples:
|
|||
RunE: runUpdate,
|
||||
}
|
||||
|
||||
updateCmd.PersistentFlags().StringVar(&updateChannel, "channel", "stable", "Release channel: stable, beta, alpha, or dev")
|
||||
updateCmd.PersistentFlags().StringVar(&updateChannel, "channel", "stable", "Release channel: stable, beta, alpha, prerelease, or dev")
|
||||
updateCmd.PersistentFlags().BoolVar(&updateForce, "force", false, "Force update even if already on latest version")
|
||||
updateCmd.Flags().BoolVar(&updateCheck, "check", false, "Only check for updates, do not apply")
|
||||
updateCmd.Flags().IntVar(&updateWatchPID, "watch-pid", 0, "Internal: watch for parent PID to die then restart")
|
||||
|
|
@ -73,7 +72,7 @@ func runUpdate(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
currentVersion := cli.AppVersion
|
||||
normalizedChannel := strings.TrimSpace(strings.ToLower(updateChannel))
|
||||
normalizedChannel := normaliseGitHubChannel(updateChannel)
|
||||
|
||||
cli.Print("%s %s\n", cli.DimStyle.Render("Current version:"), cli.ValueStyle.Render(currentVersion))
|
||||
cli.Print("%s %s/%s\n", cli.DimStyle.Render("Platform:"), runtime.GOOS, runtime.GOARCH)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ type UpdateServiceConfig struct {
|
|||
// repository URL (e.g., "https://github.com/owner/repo") or a base URL
|
||||
// for a generic HTTP update server.
|
||||
RepoURL string
|
||||
// Channel specifies the release channel to track (e.g., "stable", "prerelease").
|
||||
// Channel specifies the release channel to track (e.g., "stable", "beta", or "prerelease").
|
||||
// "prerelease" is normalised to "beta" to match the GitHub release filter.
|
||||
// This is only used for GitHub-based updates.
|
||||
Channel string
|
||||
// CheckOnStartup determines the update behavior when the service starts.
|
||||
|
|
@ -134,5 +135,8 @@ func normaliseGitHubChannel(channel string) string {
|
|||
if channel == "" {
|
||||
return "stable"
|
||||
}
|
||||
if channel == "prerelease" {
|
||||
return "beta"
|
||||
}
|
||||
return channel
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,15 @@ func TestNewUpdateService(t *testing.T) {
|
|||
isGitHub: true,
|
||||
wantChannel: "beta",
|
||||
},
|
||||
{
|
||||
name: "GitHub prerelease channel maps to beta",
|
||||
config: UpdateServiceConfig{
|
||||
RepoURL: "https://github.com/owner/repo",
|
||||
Channel: " prerelease ",
|
||||
},
|
||||
isGitHub: true,
|
||||
wantChannel: "beta",
|
||||
},
|
||||
{
|
||||
name: "Invalid GitHub URL",
|
||||
config: UpdateServiceConfig{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue