Skip to content

Git designed for AI agents.

changelog: cut the intents file only when it holds a torn line

Federico Elia007b3d14a157
diff --git a/internal/graft/changelog/lands_intents.go b/internal/graft/changelog/lands_intents.go
index e623ab8..656b51d 100644
--- a/internal/graft/changelog/lands_intents.go
+++ b/internal/graft/changelog/lands_intents.go
@@ -120,8 +120,10 @@ func RecordLandIntents(repoPath, reference, invocation string, lands []Land) (co
buf.WriteByte('\n')
}
- if err := truncateFile(f, end); err != nil {
- return false, fmt.Errorf("truncating land intents: %w", err)
+ if end < info.Size() {
+ if err := truncateFile(f, end); err != nil {
+ return false, fmt.Errorf("truncating land intents: %w", err)
+ }
}
if _, err := f.WriteAt(buf.Bytes(), end); err != nil {
return false, fmt.Errorf("writing land intents: %w", err)