From 4bb350d61b26afcaafe5c92b005afd9e72577021 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 28 Feb 2026 23:59:59 -0700 Subject: [PATCH] fix(monorel): init only auto-commits new .goreleaser.yaml, not updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Track isNewFile before writing so updates to existing files are never auto-committed (mirrors the same rule already in processModule/release) - Gate auto-bump on isNewFile as well — no tag when just refreshing yaml - Fix commit message scope: chore(): add .goreleaser.yaml (was chore(release): add .goreleaser.yaml for ) --- tools/monorel/main.go | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/tools/monorel/main.go b/tools/monorel/main.go index 8c5a6b7..ea0609f 100644 --- a/tools/monorel/main.go +++ b/tools/monorel/main.go @@ -312,9 +312,13 @@ func initModuleGroup(group *moduleGroup, dryRun bool) { prefixParts := strings.Split(prefix, "/") projectName := prefixParts[len(prefixParts)-1] - // 1. Write .goreleaser.yaml. + // 1. Write .goreleaser.yaml (always regenerate so it stays current). yamlContent := goreleaserYAML(projectName, bins) yamlPath := filepath.Join(modRoot, ".goreleaser.yaml") + isNewFile := true + if _, err := os.ReadFile(yamlPath); err == nil { + isNewFile = false + } if dryRun { fmt.Fprintf(os.Stderr, "[dry-run] would write %s\n", yamlPath) } else { @@ -323,14 +327,15 @@ func initModuleGroup(group *moduleGroup, dryRun bool) { } fmt.Fprintf(os.Stderr, "wrote %s\n", yamlPath) - // 2. Stage and commit if the file changed. - mustRunIn(modRoot, "git", "add", ".goreleaser.yaml") - if status := runIn(modRoot, "git", "status", "--porcelain", "--", ".goreleaser.yaml"); status != "" { - commitMsg := "chore(release): add .goreleaser.yaml for " + projectName - mustRunIn(modRoot, "git", "commit", "-m", commitMsg) - fmt.Fprintf(os.Stderr, "committed: %s\n", commitMsg) - } else { - fmt.Fprintf(os.Stderr, "note: .goreleaser.yaml unchanged, skipping commit\n") + // 2. Auto-commit — only when the file was newly created. + // Updates to an existing file require manual review and commit. + if isNewFile { + mustRunIn(modRoot, "git", "add", ".goreleaser.yaml") + if status := runIn(modRoot, "git", "status", "--porcelain", "--", ".goreleaser.yaml"); status != "" { + commitMsg := "chore(" + prefix + "): add .goreleaser.yaml" + mustRunIn(modRoot, "git", "commit", "-m", commitMsg) + fmt.Fprintf(os.Stderr, "committed: %s\n", commitMsg) + } } } @@ -338,8 +343,9 @@ func initModuleGroup(group *moduleGroup, dryRun bool) { // commit since the last stable tag (the common "first setup" scenario). // If other commits are already waiting to be tagged the user should choose // the right semver component with an explicit 'monorel bump'. - shouldBump := true - if !dryRun { + // Auto-bump only applies when the yaml was newly created. + shouldBump := isNewFile + if !dryRun && isNewFile { latestStable := findLatestStableTag(modRoot, prefix) if latestStable != "" { logOut := strings.TrimSpace(runIn(modRoot, "git", "log", "--oneline", latestStable+"..HEAD", "--", "."))