mirror of
https://github.com/therootcompany/golib.git
synced 2026-03-02 23:57:59 +00:00
fix(monorel): skip writing .goreleaser.yaml when content is unchanged
Compare generated content against the file on disk before writing. If identical, do nothing — no write, no "wrote" message, no commit attempt.
This commit is contained in:
parent
4bb350d61b
commit
ed08958157
@ -312,16 +312,17 @@ func initModuleGroup(group *moduleGroup, dryRun bool) {
|
||||
prefixParts := strings.Split(prefix, "/")
|
||||
projectName := prefixParts[len(prefixParts)-1]
|
||||
|
||||
// 1. Write .goreleaser.yaml (always regenerate so it stays current).
|
||||
// 1. Write .goreleaser.yaml only when the content has changed.
|
||||
yamlContent := goreleaserYAML(projectName, bins)
|
||||
yamlPath := filepath.Join(modRoot, ".goreleaser.yaml")
|
||||
isNewFile := true
|
||||
if _, err := os.ReadFile(yamlPath); err == nil {
|
||||
isNewFile = false
|
||||
}
|
||||
existing, readErr := os.ReadFile(yamlPath)
|
||||
isNewFile := readErr != nil
|
||||
isChanged := isNewFile || string(existing) != yamlContent
|
||||
if dryRun {
|
||||
if isChanged {
|
||||
fmt.Fprintf(os.Stderr, "[dry-run] would write %s\n", yamlPath)
|
||||
} else {
|
||||
}
|
||||
} else if isChanged {
|
||||
if err := os.WriteFile(yamlPath, []byte(yamlContent), 0o644); err != nil {
|
||||
fatalf("writing %s: %v", yamlPath, err)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user