Skip to content

fix(undo): auto-prune snapshots to prevent unbounded growth#23

Merged
boneskull merged 1 commit intomainfrom
prune
Feb 4, 2026
Merged

fix(undo): auto-prune snapshots to prevent unbounded growth#23
boneskull merged 1 commit intomainfrom
prune

Conversation

@boneskull
Copy link
Copy Markdown
Owner

Snapshots are now automatically pruned when counts exceed 50:

  • Active snapshots pruned during Save()
  • Archived snapshots pruned during Archive()

Oldest files are removed first based on timestamp in filename.

Snapshots are now automatically pruned when counts exceed 50:
- Active snapshots pruned during Save()
- Archived snapshots pruned during Archive()

Oldest files are removed first based on timestamp in filename.
Copilot AI review requested due to automatic review settings February 4, 2026 04:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements automatic pruning of undo snapshots to prevent unbounded growth in the .git/stack-undo/ directory. When snapshot counts exceed 50, the oldest files are automatically removed based on timestamp ordering in filenames.

Changes:

  • Added automatic pruning logic that triggers during snapshot save and archive operations
  • Implemented comprehensive tests to verify pruning behavior for both active and archived snapshots
  • Updated documentation to inform users about the automatic cleanup feature

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/undo/undo.go Added pruning logic with maxActiveSnapshots and maxArchivedSnapshots constants (50 each), modified Save() and Archive() to call pruneDir(), and implemented pruneDir() function to remove oldest snapshots when limits are exceeded
internal/undo/undo_test.go Added TestSavePrunesOldSnapshots to verify active snapshot pruning and TestArchivePrunesOldSnapshots to verify archived snapshot pruning
README.md Updated documentation to explain that snapshots are automatically pruned to keep at most 50 pending and 50 archived, with no manual cleanup required

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@boneskull boneskull merged commit d298e99 into main Feb 4, 2026
14 checks passed
@boneskull boneskull deleted the prune branch February 4, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants