fix: improve git walking termination and error handling in changelog generator

## CHANGES

- Add storer import for proper git iteration control
- Use storer.ErrStop instead of nil for commit iteration termination
- Handle storer.ErrStop as expected condition in git walker
- Update cache comment to clarify Unreleased version skipping
- Change custom patterns warning to stderr output
- Add storer to VSCode spell checker dictionary
This commit is contained in:
Kayvan Sylvan
2025-07-14 22:34:13 -07:00
parent c369425708
commit 9e4ed8ecb3
4 changed files with 10 additions and 3 deletions

View File

@@ -99,6 +99,7 @@
"seaborn",
"semgrep",
"sess",
"storer",
"Streamlit",
"stretchr",
"talkpanel",

View File

@@ -131,7 +131,7 @@ func (g *Generator) collectData() error {
// Save any new versions to cache (after potential AI processing)
if currentTag != cachedTag {
for _, version := range g.versions {
// Skip versions that were already cached
// Skip versions that were already cached and Unreleased
if version.Name != "Unreleased" {
if err := g.cache.SaveVersion(version); err != nil {
fmt.Fprintf(os.Stderr, "Warning: Failed to save version to cache: %v\n", err)

View File

@@ -10,6 +10,7 @@ import (
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/storer"
)
var (
@@ -317,7 +318,7 @@ func (w *Walker) WalkHistorySinceTag(sinceTag string) (map[string]*Version, erro
err = commitIter.ForEach(func(c *object.Commit) error {
// Stop when we reach the tag commit
if c.Hash == tagCommit.Hash {
return nil
return storer.ErrStop
}
commit := &Commit{
@@ -369,6 +370,11 @@ func (w *Walker) WalkHistorySinceTag(sinceTag string) (map[string]*Version, erro
return nil
})
// Handle the stop condition - storer.ErrStop is expected
if err == storer.ErrStop {
err = nil
}
return versions, err
}

View File

@@ -337,7 +337,7 @@ func (o *PatternsLoader) createUniquePatternsFile() (err error) {
}
fmt.Printf("📂 Also included patterns from custom directory: %s\n", o.Patterns.CustomPatternsDir)
} else {
fmt.Printf("Warning: Could not read custom patterns directory %s: %v\n", o.Patterns.CustomPatternsDir, customErr)
fmt.Fprintf(os.Stderr, "Warning: Could not read custom patterns directory %s: %v\n", o.Patterns.CustomPatternsDir, customErr)
}
}