diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 3b5fceb..7d3f754 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -58,10 +58,23 @@ jobs: TAG="${{ github.event.inputs.tag || github.ref_name }}" API="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/releases" + # Collect commits since the previous tag (or last 20 if no prior tag) + PREV_TAG=$(git tag --sort=-version:refname | grep -v "^${TAG}$" | head -1) + if [ -n "$PREV_TAG" ]; then + RANGE="${PREV_TAG}..${TAG}" + else + RANGE="HEAD~20..HEAD" + fi + NOTES=$(git log "$RANGE" --pretty=format:"- %s" --no-merges) + BODY="## What's changed"$'\n'"${NOTES}" + + # Escape for JSON + BODY_JSON=$(printf '%s' "$BODY" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))') + RELEASE=$(curl -s -X POST "$API" \ -H "Authorization: token ${GITHUB_TOKEN}" \ -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"body\":\"Release ${TAG}\"}") + -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"body\":${BODY_JSON}}") UPLOAD_URL=$(echo "$RELEASE" | grep -o '"upload_url":"[^"]*"' | cut -d'"' -f4) if [ -z "$UPLOAD_URL" ]; then diff --git a/cmd/edit.go b/cmd/edit.go index 2dea59b..95d42ed 100644 --- a/cmd/edit.go +++ b/cmd/edit.go @@ -21,7 +21,15 @@ func init() { func runEdit(cmd *cobra.Command, args []string) error { editor := os.Getenv("EDITOR") if editor == "" { - editor = "vi" + for _, e := range []string{"nvim", "nano", "vi"} { + if _, err := exec.LookPath(e); err == nil { + editor = e + break + } + } + } + if editor == "" { + return fmt.Errorf("no editor found; set $EDITOR") } c := exec.Command(editor, configPath) c.Stdin = os.Stdin diff --git a/cmd/syncup.go b/cmd/syncup.go index 6e7f02f..32d60e5 100644 --- a/cmd/syncup.go +++ b/cmd/syncup.go @@ -31,6 +31,7 @@ func runSyncup(cmd *cobra.Command, args []string) error { } added := 0 + unchanged := 0 discovered := map[string]bool{} // Discover running containers across all runtimes @@ -51,6 +52,8 @@ func runSyncup(cmd *cobra.Command, args []string) error { if cfg.AddUnit(unit) { fmt.Printf(" + added: %s (%s)\n", c.Name, c.Runtime) added++ + } else { + unchanged++ } } } @@ -86,6 +89,6 @@ func runSyncup(cmd *cobra.Command, args []string) error { return err } - fmt.Printf("\nDone. Added: %d Disabled: %d Re-enabled: %d\n", added, disabled, reenabled) + fmt.Printf("\nDone. Added: %d Unchanged: %d Disabled: %d Re-enabled: %d\n", added, unchanged, disabled, reenabled) return nil } diff --git a/runtime/podman.go b/runtime/podman.go index d49c950..0c0b459 100644 --- a/runtime/podman.go +++ b/runtime/podman.go @@ -15,7 +15,7 @@ type podmanContainer struct { ID string `json:"Id"` Names []string `json:"Names"` Image string `json:"Image"` - Command string `json:"Command"` + Command []string `json:"Command"` State string `json:"State"` } @@ -55,7 +55,7 @@ func (p *Podman) ListRunning() ([]Container, error) { containers = append(containers, Container{ Name: name, Image: c.Image, - Command: c.Command, + Command: strings.Join(c.Command, " "), Runtime: "podman", }) }